Method and apparatus for linking routines for different contexts

ABSTRACT

A method and apparatus for associating routines for controlling user actions in a computer-controlled display system. Each of a first of plurality of routines may be linked for controlling the computer-controlled display system when the system is in a first context. Each of the first plurality of routines may control different aspects of the functioning of the display system, such as the functioning of various user interface objects on the display. Further, a second plurality of routines may be linked for controlling the system when the system is in a second context. Each of the pluralities of routines are activated when the system is either in the first or second context.

This is a continuation of application Ser. No. 08/026,323, filed Mar. 3,1993, now abandoned.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a method and apparatus for themanipulation of data in a computer system and the visual feedback whichis provided thereof. More specifically, the present invention relates toan improved method and apparatus for selection and information from onelocation to another in a user interface display to cause certain actionsto occur.

2. Background Information

Existing graphical user interfaces (GUI's) in computer systems provide avariety of tools to manipulate information. One of the key designcharacteristics of graphical user interface is the concept of directmanipulation. Traditional disk operating systems used a command lineinterface (such as the MS DOS operating system available from MicrosoftCorporation of Redmond, Wash.), and English language commands are issuedby a user in order to cause certain events to occur. In modem GUI's,ties and other information are directly manipulated by selecting iconsrepresenting files and moving the icons while selected on the computersystem display. In this manner, files may be moved, copied, deleted, andotherwise manipulated in the fie system of the computer.

An example of this process is shown in FIGS. 1a-1d. For example, in FIG.1a, in a window 100, which is displayed on a computer system display,the user may select an icon 120 representing a file using a cursorpointer 110 which is under user control using a mouse, trackball, orother cursor control device. Once selected the user may move ormanipulate the icon in any manner in order to perform certain actions inthe file system. Icon 120 is shown in its selected state in window 100of FIG. 1a. Then, as is illustrated in FIG. 1b, the user may start tomove cursor 110 while the icon is selected causing an outline imagerepresentation of the icon and its file name, which is illustrated as130, to be moved on the computer system display. This allows the user tomanipulate the file for movement within the file system. Then, as isillustrated in FIG. 1c, the user may move pointer 110 to a subdirectoryentitled "Documents," shown as 140 in FIG. 1c (also known as a "folder"in the Macintosh® brand operating system), for movement of that file inthe file system. When the "folder" icon 140 is pointed to by pointer110, it becomes shown in its highlighted state, as is illustrated inFIG. 1c. Then, as is illustrated in FIG. d, when the user deselects theicon (that is, releases a mouse button or other selection means), theoriginal icon 120 disappears from the window, and icon 140 is shown inan unselected state. In addition to the visual representation on window100 as is illustrated in FIG. 1d, the file has been moved from thedirectory which window 100 represents to the subdirectory "Documents"represented by icon 140. For accessing the file represented by icon 120at a later time, the user will select icon 140 causing a second windowto be displayed representing that subdirectory and be able to access thefile represented by icon 120. Thus, movements within the file system andreorganization of files in the file system, known as the HFS(Hierarchical Filing System) in the Macintosh® brand operating system,may be performed using this prior art technique.

Another prior an implementation of a movement of information in agraphical user interface such as that used by the Macintosh® brandoperating system is illustrated with reference to FIGS. 2a-2d. Forexample, this is a process which may be used for transferring textbetween a window displaying one set of text (e.g., 210) and a secondwindow with a second set of text in it (e.g., 220). As is illustrated inFIG. 2a, the user will select a region of text in document 210 utilizingcursor 200 under control of the cursor control and selection device andselect an option from a pull-down menu 230, such as "Cut" 230a. This isa destructive move operation wherein the text is removed from document210 and will be moved to document 220. This is all illustrated in FIG.2a. Then, the user will move the cursor to second document 220 in textarea 220a and select a region in the text at which he desires the textto be moved. The cursor in text region 220a will change to a formatknown as insertion carat 250 which indicates where the insertion pointwill be. Then, as is illustrated in FIG. 2c, the user will use pull-downmenu 230 again, selecting a second option "Paste" 230b to retrieve text240 from an intermediate storage device, such as a clipboard or othertype of intermediate storage buffer, and insert the text at thatlocation. As is illustrated in FIG. 2c, the text is still highlighted asthis is shown immediately after the paste operation. Then, thehighlighting is removed, as is illustrated in FIG. 2d, when the userselects other regions of the screen to operate in or performs otheroperations. Thus, as is illustrated in FIG. 2d, the destructive moveoperation from Document 1 210 to Document 2 220 has been accomplished.As is well-known to those skilled in the prior art, nondestructive"copy" operations may also be performed in a similar manner by selectingother pull-down menu options on pull-down menus such as FIGS. 2a and 2c.Note that the documents 210 and 220 may be under control of a singleprogram, such as a word processing program, or may be under control ofdifferent application programs, such as one word processing program anda second word processing program or any other type of applicationprogram. As is well-known to those skilled in the prior art, transferamong different types of application programs may be accomplished usingthe cut and paste operations described with reference to FIGS. 2a-2d ona variety of architectural platforms using the intermediate storagebuffer known as the clipboard. Other types of information such asgraphical information, numeric information, or other types ofinformation may be transferred in this manner.

Upon viewing FIGS. 1a-1d and 2a-2d, it is apparent that there is adichotomy between the two techniques. Users become used to themanipulation of files in the manner which is illustrated with referenceto FIGS. 1a-1d, however, the user must learn the use of a second toolknown as the "Edit" pull-down menu illustrated as 230 in FIGS. 2a-2d inorder to perform manipulation of information between windows and/orapplication programs and/or files. Thus, there is a need for improvedmanipulations of various types of data, especially between applicationprograms than techniques which exist in the prior art.

SUMMARY AND OBJECTS OF THE INVENTION

One of the objects of the present invention is to provide an improvedmethod and apparatus for manipulating information in a computer system.

Another of the objects of the present invention is to provide aconsistent user interface for manipulation of information between andwithin application programs and within an operating system.

Another of the objects of the present invention is to provide animproved means for providing feedback to a user of manipulation ofinformation in a computer system.

Another of the objects of the present invention is to provide anarchitecture for direct manipulation of data to and from applicationprograms and files in a file system.

These and other objects of the present invention are provided for by amethod and apparatus of associating various routines for controllinguser actions in a computer-controlled display system. The methodcomprises linking a first plurality of routines for controlling thecomputer-controlled display system when the system is in a firstcontext. Further, a second plurality of routines for controlling thedisplay system is linked for controlling the system when it is in asecond context. Each of the linked routines in the first plurality andsecond plurality of routines is used for controlling different aspectsof the functioning of the system. When the system is in the firstcontext the first plurality of routines is caused to be activated,wherein each of the plurality of routines performs an action in thesystem, such as the highlighting of user interface objects and otheractions, to provide feedback to a user. Further, these routines may alsocommunicate data to and from other routines in the system. Moreover, thesecond plurality of routines is activated upon detection of the secondcontext. Each of the routines is executed in sequential order accordingto the order in which they were linked.

Other features, advantages, and novel aspects of the present inventionwill become apparent from the detailed description which follows below.

BRIEF DESCRIPTION OF DRAWINGS

The present invention is illustrated by way of example and notlimitation in the figures of the accompanying in which like referencesindicate like elements and in which:

FIGS. 1a-1d show a prior art method for selecting an icon representing afile and moving it to a second location using a graphical userinterface.

FIGS. 2a-2d show a prior art method of copying text from a first file ona user interface display to a second file on the user interface display.

FIG. 3 shows a block diagram of a computer system upon which the methodsand apparatus of the preferred embodiment may be implemented.

FIG. 4 shows the interaction model used by the preferred embodiment toprovide various user interface feedback during drag-and-drop operations.

FIGS. 5a-5d show an operation which may be implemented for selectingtext from a first application program and dropping it in a secondapplication program containing graphic data.

FIGS. 6a-6c show a sequence of steps which may be used on a graphicaluser interface for dragging graphic data from a first user interfacewindow to a second window containing text.

FIGS. 7a-7d show a method for selecting an item within a user interfacewindow and dragging and dropping that item into a window controlled bythe file system to create a file representative of the item selected.

FIGS. 8a-8d illustrate an example of background selection used in theuser interface of the preferred embodiment.

FIGS. 9a-9d illustrate a method for performing a system service usingthe graphical user interface of the preferred embodiment.

FIGS. 10a-11 illustrate the appearance on a display of a graphical userinterface while selecting and dragging multiple objects.

FIGS. 12-13b show examples of selection feedback which may be providedfor a graphical object using the user interface of the preferredembodiment.

FIGS. 14a and 14b show an example of drag feedback which may be providedfor text items.

FIGS. 15a-15d illustrate autoscrolling which may be performed upon thegraphical user interface of the preferred embodiment.

FIGS. 16-18d illustrate examples of various destination feedback whichmay be provided by the graphical user interface of the preferredembodiment.

FIGS. 19a-19d illustrate examples of dragging text within a singleapplication window and between application windows.

FIGS. 20a-20d show an example of abort feedback which illustrates anappearance on a display when an operation cannot be completedsuccessfully.

FIG. 21 illustrates a selection dialog window which may be used forselecting verbs or actions to be performed during a drag-and-dropoperation.

FIG. 22 illustrates an example of a tracking handler registry forvarious windows which are handled by a particular application program.

FIG. 23 shows a selected item and a series of windows which may betraversed during a drag-and-drop operation.

FIG. 24 shows a graphical representation of the data structure used formaintaining a list of selected items for a drag operation.

FIG. 25 shows an example of a series of drag items placed into a dragitem list for use during a drag-and-drop operation.

FIGS. 26 and 27 illustrate the transfer of control and context switcheswhich occur between application programs in typical prior an systems.

FIGS. 28 and 29 illustrate transfers of control which may be implementedin one embodiment of the present invention.

FIGS. 30 and 31 illustrate the drag tracking process as performed withinthe preferred embodiment.

FIG. 32 illustrates a process which is performed in a normal event loopof an application program for commencing a drag from an activeapplication program.

FIGS. 33a and 33b illustrate a process which is performed during theselection and drag of items in a background or inactive applicationprogram.

FIG. 34 illustrates a flow diagram of a process which is performed whena drop operation takes place in the preferred embodiment.

FIG. 35 shows a process for a highlighting a region on a display forimproved user interface feedback.

FIGS. 36a-36c illustrate methods for maintaining highlighting in windowsduring scrolling operations.

FIG. 37 shows an example process for providing abort or completionfeedback.

FIGS. 38a-38d illustrate a process for creating a clipping file in thefile system of the a computer system.

FIG. 39 shows a process implemented for selecting verbs which may beimplemented in one embodiment of the present invention.

DETAILED DESCRIPTION

A process and apparatus for an improved manipulation of data and userfeedback in a computer-controlled display system is described. In thefollowing description, specific steps, procedures, command options,command items, and other specifics are set forth in order to provide athorough understanding of the present invention. However, it will beapparent to one skilled in the art that the present invention may bepracticed without these specific details. In other instances, well-knownsystems and methods are shown in diagrammatic, block or flow diagramform in order to not unnecessarily obscure the present invention.

System of the Preferred Embodiment

Referring to FIG. 3, the computer system upon which a preferredembodiment of the present invention is implemented is shown as 300. 300comprises a bus or other communication means 301 for communicatinginformation, and a processing means 302 coupled with bus 301 forprocessing information. System 300 further comprises a random accessmemory (RAM) or other volatile storage device 304 (referred to as mainmemory), coupled to bus 301 for storing information and instructions tobe executed by processor 302. Main memory 304 also may be used forstoring temporary variables or other intermediate information duringexecution of instructions by processor 302. Computer system 300 alsocomprises a read only memory (ROM) and/or other static storage device306 coupled to bus 301 for storing static information and instructionsfor processor 302, and a data storage device 307 such as a magnetic diskor optical disk and its corresponding disk drive. Dam storage device 307is coupled to bus 301 for storing information and instructions. Computersystem 300 may further be coupled to a display device 321, such as acathode ray tube (CRT) or liquid crystal display (LCD) coupled to bus301 for displaying information to a computer user. An alphanumeric inputdevice 322, including alphanumeric and other keys, may also be coupledto bus 301 for communicating information and command selections toprocessor 302. An additional user input device is cursor control 323,such as a mouse, a trackball, stylus, or cursor direction keys, coupledto bus 301 for communicating direction information and commandselections to processor 302, and for controlling cursor movement ondisplay 321. Another device which may be coupled to bus 301 is hard copydevice 324 which may be used for printing instructions, data, or otherinformation on a medium such as paper, film, or similar types of media.Note, also, that any or all of the components of system 300 andassociated hardware may be used in a preferred embodiment, however, itcan be appreciated that any type of configuration of the system may beused for various purposes as the user requires.

In the preferred embodiment, computer system 300 is one of theMacintosh® family of personal computers such as the Macintosh® Quadra™or Macintosh® Performa™ brand personal computers manufactured by Apple®Computer, Inc. of Cupertino, Calif. (Apple, Macintosh, Quadra, andPerforma are trademarks of Apple Computer, Inc.). Processor 302 is oneof the 68000 family of microprocessors, such as the 68030 or 68040manufactured by Motorola, Inc. of Schaumburg, Ill.

Note that the following discussion of the methods and apparatus of thepreferred embodiment discussed herein will refer specifically to aseries of routines which are compiled, linked, and then run as objectcode in computer system 300 during run-time. It can be appreciated byone skilled in the art, however, that the foregoing methods andapparatus may be implemented in special purpose hardware devices, suchas discrete logic devices, large scale integrated circuits (LSI's),application-specific integrated circuits (ASIC's), or other specializedhardware. The description here has equal application to other apparatushaving similar function.

User Interface of the Preferred Embodiment

Before discussing the preferred embodiment in detail, a brief overviewof the user interface used in this system is required. A "windowing" orgraphical user interface (GUI) operating environment is used whereinselections are performed using a cursor control device such as 323 shownin FIG. 3. Typically, an item is "selected" on a computer system displaysuch as 321 using cursor control device 323 by positioning a cursor, orother indicator, on the screen over (or in proximity to) an object onthe screen and by depressing a "selection" button which is typicallymounted on or near the cursor control device. The object on the screenis often an icon which has an associated file or operation which theuser desires to use in some manner. In order to launch a userapplication program, in some circumstances, the user merely selects anarea on a computer display represented as an icon by "double clicking"the area on the screen. A "double click" selection is an operationcomprising, while positioning the cursor over the desired object (e.g.,an icon), two rapid activations of the selection device by the user."Pull-down" or "pop-up" menus are alto used in the preferred embodiment.A pull-down or pop-up menu is a selection which is accessible bydepressing the selection button when the cursor is pointing at alocation on a screen such as a menu bar (typically at the top of thedisplay), and "dragging" (moving cursor control device 323 while theselection button is depressed) until the selection the user wishes toaccess is reached on the pull-down menu. An item is indicated as being"selected" on a pull-down menu when the item is highlighted or displayedin "reverse video" (white text on a black background). The selection isperformed by the user releasing the selection device when the selectionhe wishes to make is highlighted. Also, in some GUI's, as is describedin the background above, the "selection" and "dragging" of items isprovided to move files about in the file system or perform other systemfunctions. These techniques include "dragging and dropping" whichcomprises making a "selection" of an icon at a first location,"dragging" that item across the display to a second location, and"dropping" (e.g., releasing the selection device) the item at the secondlocation. This may cause the movement of a file to a subdirectoryrepresented by the second location.

Note also that GUI's may incorporate other selection devices, such as astylus or "pen" which may be interactive with a display. Thus, a usermay "select" regions (e.g., an icon) of the GUI on the display bytouching the stylus against the display. In this instance, such displaysmay be touch or light-sensitive to detect where and when the selectionoccurs. Such devices may thus detect screen position and the selectionas a single operation instead of the "point (i.e., position) and click(e.g., depress button)," as in a system incorporating a mouse ortrackball. Such a system may also lack a keyboard such as 322 whereinthe input of text is provided via the stylus as a writing instrument(like a pen) and the user handwritten text is interpreted usinghandwriting recognition techniques. These types of systems may alsobenefit from the improved manipulation and user feedback describedherein.

Overview of the Preferred Embodiment

The preferred embodiment is a series of enhanced methods and apparatuswhich allow direct manipulation of data to and from application programsin the operating and/or file management system. These methods andapparatus are implemented using a variety of novel approaches,including, but no limited to: improved user interface feedback formanipulation of information in the computer system; improvedarchitectural functionality for transfer of control to and from variousapplication programs, handlers, and other system services which servicethose application programs; improved activation and use of systemservices; combinations of immediate data transmission or deferral oftime-intensive techniques such as data translation and/or datacommunication until such time as required to minimize interaction delaysand increase performance of the manipulation actions; and the creationof files representing discrete portions of files for later use. For theremainder of this application, in the preferred embodiment, the improveduser functionality and user feedback is provided via a system toolboxroutine known as the Drag Manager.

The Drag Manager provides capabilities for various application programswhich have interapplication dragging capability to identify the formatsof data that they are capable of providing information in. These datatypes will be known, for the remainder of this application, as"flavors."

Interaction Model of the Preferred Embodiment

The improved user interface used by the preferred embodiment may beeasily described with reference to the interaction model of FIG. 4. Theinteraction model has modified and broadened the use of techniques, suchas "dragging and dropping," to provide certain inventive and usefuladvantages. The interaction model comprises several features which havea richer set of data items and destinations which may be used forselecting and manipulating (e.g., "dragging and dropping") in the userinterface of system 300. The interaction model has several componentssuch as the selection of an object, which is illustrated as 401, whichprovides certain selection feedback displayed upon display 321 to a useroperating system 300 which has an improved appearance. Furthermore, whena "drag" occurs (a selection which is being moved on the display), thepreferred embodiment comprises new methods for illustrating to a userthat the dragging operation is occurring, as is illustrated by block402. While the drag is being performed, improved navigation techniquesare provided, as is illustrated by block 405, which provides improvedmethods of displaying various information during the movement operationon the user interface display, such as movement within windows, etc.Once the destination is arrived at by the user at the end of the dragoperation (for example, indicated by deactivating the selection signal),then there are improved user interface objects, illustrated as block403, which provides improved destination feedback, such as whether acontainer can receive an object. This model also provides certainfeedback to the user when destination is reached, and the operation iscompleted successfully when a "drop" occurs (drop feedback block 404),or the destination is either invalid or incapable receiving theinformation by showing improved abort feedback (block 406). All of theobjects are under control of user actions and system actions, as isillustrated by block 410.

For the remainder of this application, the manipulation of informationin the manner discussed below will be known as "drag-and-dropsequences," and these techniques encompass a wide variety of userinterface actions to perform system services or other actions in thecomputer system.

Up until now, drag-and-drop sequences that span windows have beenlimited to objects characterized as containers. For example, documentsare containers of content, and these documents could be dragged onlyacross folder windows (e.g., directories), disk windows (iconsrepresenting media devices), and the main display of the operatingsystem known as the "Finder." Also, dragging content itself (e.g.,graphics) has been limited to certain types in a single window. Forexample, objects in a graphics application program can be dragged toanother position in the same window, but cannot be dragged to anothercontrolled by the same application program. The preferred embodimentmakes it easier to eliminate these limitations; ideally, users should beable to drag any content from any window to any other window thataccepts the content's type. This new capability leads to ageneralization of the interaction model, where "objects" and"destinations" take on broader meanings.

Another extension to the prior art drag-and-drop sequence is the abilityto navigate while dragging, as shown in the interaction model above.This navigation includes opening windows, scrolling, finding, and windowhierarchy changes.

Interapplication Dragging

The preferred embodiment provides for one interapplication dragging ofdata. That is, users are not limited to selecting and dragginginformation within a single application program but may select and dragthis information across application boundaries to windows control bydifferent application programs. This is accomplished, in the preferredembodiment, with all necessary translation of information (if required)being transparent to the user and deferral of time-intensive tasks, suchas data communication and translating, until actually requested by thereceiver. A detailed implementation of this interface will be discussedin more detail below, however, one example is illustrated with referenceto FIGS. 5a-5d. For example, as illustrated in FIG. 5a, two windows maybe present on the display screen, such as 510 and 520. 510 may be awindow under control of a word processing program, and window 520 may beunder control of a second program such as a computer graphics program.As is illustrated in FIG. 5a, the user, using the pointing device (e.g.,323) to control cursor 500 on user interface display 321, may select aregion such as 501 in window 510 which he wishes to move or copy to asecond document window 520, such as that handled by graphics program.Using well-known techniques, the user selects text region 501 (e.g.,blocks out a region of text and selects the blocked regions) and startsto move the text across the window boundary. This is illustrated at FIG.5b.

Note that once movement of selected information 501 takes place, theselection changes to an outline representation of a rectangular boxhaving the shape of the blocked text 501 shown as 505 shown in FIG. 5b.Then, the user arrives at the destination in window 520 to complete thedrag of the selected information 505 from window 510 to 520, asillustrated in FIG. 5c. Upon reaching the location in window 520, theselection device is deactivated (e.g., the mouse button is released),and the text or other information which was present in window 510 is nowcopied in region 506 in window 520 as illustrated in FIG. 5d. Anotherinteresting behavior to note from viewing FIGS. 5a-5d is that the"background" application program which is in control of window 520 neverbecomes activated. This is illustrated by its title bar 520a remainingin its inactive representation (e.g., the clear representation), whereasthe front window 510's title bar 510a remains in the "active" state. Inprior an drag-and-drop operations, the destination window becomes thefront-most window upon the detection of a selection within the window,and it tends to obscure the other window(s) shown on the display.Moreover, the preferred embodiment does not activate the inactiveapplication program (e.g., controlling window 520), but instead, allowsthe hierarchy of windows which was originally displayed, such asillustrated in FIG. 5a, to remain the same. In this way, the originalappearance of the display is not modified in any way, unless the userdesires, and drag-and-drop operations do not cause unintended anddistracting changes to the windows on the display.

Other types of data such as graphics may also be moved in a similarmanner. This is illustrated with reference to FIGS. 6a-6c. First, usingthe cursor control device 323 to control cursor 600, the user selectsthe graphic data to be moved. Graphic data may be selected usingwell-known selection techniques (e.g., by drawing a bounding box), suchas illustrated as 601 in FIG. 6a. Of course, if the object is a discretegraphical object, such as used in object-oriented drawing programs(e.g., the MacDraw brand drawing program available from ClarisCorporation of Santa Clam, Calif.), the selection may comprise a singleselection of graphical objects 601 instead of the bouding box method.Then, the drag commences, as illustrated in FIG. 6b, wherein outline box630 of graphics 601 will be displayed during the drag. Once the userreaches the desired drop location with cursor 600 and deactivates theselection device, as illustrated in FIG. 6c, graphic data 640 is copiedto window 620. It will be apparent from the remainder of thisspecification that the capability to drag and drop different types ofinformation is provided only if the sending and receiving applicationshave a common format in which data can be transmitted. If there is nocommon format in which the data can be transmitted (e.g., text,graphics, sound, or other types of data), then abort feedback on theuser interface display will be provided from the destination or receiverapplication program window. It will be apparent from the remainder ofthis specification, however, that a wide variety of data types will beprovided for insertion into different application programs. In addition,other data types are available through the use of a system servicecalled the Translation Manager. Sending applications specify a list offormats in which the data is or may be provided, and the TranslationManager appends to that list a list of formats that it can translate thedata into. If the receiving application program cannot use any of thedata types specified by either the sending application program or theTranslation Manager, then abort feedback is provided on the user displayto indicate to the user that the drag-and-drop operation was notsuccessful. These operations will be discussed in more detail below.

Another feature which the Drag Manager provides for is the creation anduse of "clippings." This is illustrated and described with reference toFIG. 7a-7c. The user selects, using cursor 700, a region in a firstapplication program's window 710 which he desires to drag and drop to asecond location. Upon activation of the selection device, the area ishighlighted, such as 715 shown in FIG. 7a, and the user may move theselected region which the selection device is activated to any region onthe computer system display. In the example shown in FIG. 7b, thedragged region 715 is dragged to the "desktop" illustrated as 720 inFIGS. 7a-7c. In the preferred embodiment, desktop 720 is the maindirectory of the user's mass storage device 307 in the Macintosh® brandcomputer system, however, it may be any file system window, such as asubdirectory or "folder." Like the example shown in FIGS. 5a-5d and6a-6c, desktop 720 is under control of a second application program,known as the "Finder," which is the main operating system in theMacintosh® brand computer system. Thus, FIGS. 7a-7c illustrateinterapplication dragging between an application program and the filesystem manager. Upon reaching a desired file location (e.g., desktop720) at which a user wishes the data to reside, the user releases theselection device. Immediately thereafter, as illustrated in FIG. 7c, anicon 750 is mated at the location of cursor 700 when the selectiondevice was deactivated. The icon represents a file created in the filesystem which contains the data dragged from window 710. As will bediscussed in more detail below, a file is created by the File SystemManager which may be subsequently accessed by the user for insertioninto files under control of other application programs. This type oficon 750 represents a "clipping" which is a file containing the selecteddata dragged out of the application program window.

The clipping represented by icon 750 contains all file information whichwould normally be associated with the data if the data had been storedas an ordinary file. However, the creator in the Macintosh® brand systemof the clipping is the Finder instead of the application program fromwhich the data originated. Therefore, the selection of theicon-representing the clipping will call a modeless window to bedisplayed which allows the user to view the data, however, not modifythe data in any way instead of launching the application program. Thecreation of clippings in the manner discussed with reference to FIGS.7a-7c provides distinct advantages over the prior art cut-and-pastebuffer described with reference to FIGS. 2a-2d. Clippings are stored asnormal files in the hierarchical filing system (HFS) and are notretained in an intermediate memory storage location, such as theclipboard buffer normally used for cut and paste operations. Because theclipboard is stored in main memory, it is volatile and is not retainedby the computer between user sessions. Moreover, the prior art clipboardbuffer generally only contains a single item, and thus an item in theclipboard may be overwritten by another item. A user may desire toselect a large number of items to be retained for later use in otherapplication programs or later sessions, and the clipboard buffer isinadequate for this purpose. Because a clipping is stored in thecomputer system's mass media device (e.g., 307 of FIG. 3), it may beretained and used at a later data. In addition, the creation of aclipping does not cause another clipping having a different filing namein the computer system to be overwritten. A large number of clippingsmay be retained by the user in the preferred embodiment for use at alater time. Clippings have many advantages over the prior art cut andpaste operations and clipboard buffer which are in use in the prior art.

In addition to the creation of a file in the file system containing thedragged data, an icon 750 is stored representing the type of data storedwithin the clipping. Certain default icons are used in the preferredembodiment for representing text, graphic data, sound, video, etc. Also,clippings have associated with them a default name, such as 760illustrated in FIG. 7c, which may be a standard name supplied by theapplication program or a system-assigned name using some standardconvention. The name supplied by the application program may identifythe application program where the clipping originated (e.g., for a wordprocessing program, the clipping may be entitled "Word Clipping 1").

For example, the icons illustrated as 780-785 in FIG. 7d may be used forrepresenting different types of clippings in the file system. Forexample, icons 780, 781, 784, and 785 are used as default icons forrepresenting graphics, text, sound, and animation data in the preferredembodiment. Icon 782 may be used as a default icon to represent any datatype which the system does not recognize.

One unique aspect of the preferred embodiment's implementation ofclippings is the use of a "proxy" icon. This is an icon which issupplied by the application program and may fall in the dark areaillustrated in icon 783 of FIG. 7d. If a proxy has been supplied by theapplication program, than the proxy icon is used instead of the defaulticons 780-782 or 784 and 785. This proxy may be representative of thedata, such as miniature representation of text or graphics selected, astandard icon used by the application program, or other representation.This allows the user to easily identify the data at a later time bysimply viewing the icon. This provides improved interaction andidentification of clippings, in addition to the name chosen for theclipping, as discussed above. The proxy icon may be generated based uponthe data or some default icon which the application provides, as isfamiliar to those skilled in the art. The methods and apparatus forcreating a clipping, associating an icon with the clipping, and thenaming of a clipping are all discussed in more detail below.

Background Selection

Yet another aspect of the behavior of the preferred embodiment is thatof background selection. In the Macintosh® brand operating system, whena selection is made in a window, the window becomes that active windowand is brought to the front so the user may perform various actionswithin the window. In the preferred embodiment, when a selection hasbeen made in a window controlled by an application which becomesinactive (e.g., its window goes to the "back"), the selection changes toa different representation in order to provide improved control anddisplay of that information. This is illustrated with reference to FIGS.8a-8d. For example, the user may be operating in one window, such as810, and select some information. The user may then select a secondwindow 820 to bring that window to the front. 830 was previouslyselected information in a similar manner as illustrated as 501 in FIG.5a. Upon selecting window 820 to bring it to the foreground, 830 changesto an outline box representation as is illustrated in FIG. 8a. Then, theuser may select the information and drag the selected information to asecond window. The select-and-drag operation of the background windowwill be performed without bringing the source window (e.g., 810) of thedrag to the foreground. A typical background select-and-drag operationis performed as illustrated in FIGS. 8a-8d. As the first step, the userselects, using cursor 800, selected item 830, as is illustrated in FIG.8a. Then, as is illustrated in FIG. 8b, using cursor control device 323,the user drags cursor 800 towards window 820, as is illustrated in FIG.8b. Again, as in the other drag-and-drop operations, the selection ofregion 830 is displayed as an outline box. A second outline box 840provides user feedback to illustrate the information being moved to thesecond window. As illustrated in FIG. 8c, box 840 may be moved into thesecond window 820, such as that controlled by a second activeapplication program. As illustrated in FIG. 8d, the selection device maybe described while cursor 800 is in window 820, and the originalselected information 830 is copied to window 820. Note, in FIG. 8d, thatregion 830 is still maintained in its selected state even aftercompletion of the drag-and-drop operation. This will allow the user todo similar drag-and-drop operations using background selection 830 forother windows on the display. As will be discussed below, all of thedrag-and-drop operations are performed without activation of any of thebackground application(s), and as many background selection(s) asnecessary may be maintained on the user interface display.

Invocation of System Services

Another feature provided by the preferred embodiment is the invocationof certain system services through the use of drag-and-drop operations.Thus, as discussed above, in the preferred embodiment, the drag-and-dropoperations need not be performed wherein destinations represent"containers," but rather, destinations include system services whereinthe drop operation indicates the performance of that system service.This is illustrated with reference to FIGS. 9a-9d. The user may beviewing a particular window, such as 910 as illustrated in FIG. 9a. Toprint the document represented by icon 905 in FIG. 9a, the user wouldselect, by pointing cursor 900 at icon 905, icon 905 using the selectiondevice. Then, while icon 905 is selected, the user drags, and the iconis represented in its outline representation 930 shown in FIG. 9b. Thedragged box 930 may be to an icon representing a system service, such asillustrated by Laser Printer icon 920. At FIG. 9c, cursor 900 residesover icon 920 which indicates that the user desires to print thedocument represented by icon 905. As illustrated in FIG. 9d, the userreleases the selection device while the cursor is over Laser Printericon 920 thus causing a process, such as a background printing systemservice, to retrieve the document represented by icon 905 and cause itto be printed. In this manner, system services may be accessed usingselect, drag, and drop operations. The system service, such as thatcontrolling the laser printer as illustrated by icon 920, determineswhether the type of data represented by icon 905 is such that can beused by the system service (e.g., printed), and if so, then data isretrieved from the file, and the file has the action performed upon it.In this instance, the file would be retrieved and sent to the printqueue for printing by the user's computer system. Other system servicesmay be accessed in an analogous manner, such as the sending ofelectronic mail messages. This action may be performed by selecting afile containing a message and dropping it into an icon representing amail service, for example, an icon which looks like a mailbox. Otheranalogous types of operations may be performed using the drag-and-dropoperations discussed herein, and certain routines will be discussed inmore detail below.

Feedback During Navigation of Drag Operations

Feedback during the navigation of drag operations will be discussed withreference to FIGS. 10a-13b. For representing icons during dragoperations, including multiple icons which are selected, twoalternatives are shown with reference to FIGS. 10a and 10b. For example,with reference to FIG. 10a, items represented as icons in a window suchas 1000 (e.g., 1001-1005) are represented as single-pixel outlines, eachhaving the shape of the original icon and single-pixel outlines of thename for each icon shown as 1011-1015.

Similarly, as is illustrated in FIG. 10b, icons which are selected anddragged, such as 1051-1055 in window 1050, are represented withsingle-pixel outlines of the icon and the name associated with each iconare represented as single-pixel outlines, such as 1061-1065. Note that,in either of the examples of FIGS. 10a or 10b, the icons and therepresentative single-pixel outlines are represented using arbitraryshapes or the icons and are not represented using rectangular or othersimple outlines as performed in certain prior art systems. Thus,improved feedback is given to the user during dragging. Note that thearbitrary shape of the single-pixel outline and the single-pixel outlineof the name is done for one or many icons, depending on the numberselected by the user.

An alternative representation of multiple selections is shown in FIG.11. In this instance, if a large number of items, such as icons1101-1105, are selected in a window such as 1100, then a singlerectangular single-pixel outline, such as 1110, may be shown. In anyevent, this provides feedback to the user that a large amount ofinformation is being selected and dragged to a second location.

Graphic data, in contrast to an icon, is represented using either theshape of the graphic (which may an arbitrary shape) or a rectangularregion of similar size to the graphic itself. In either event, positivefeedback is provided to the user that graphic data is being selected anddragged. For example, in one instance, the drag feedback of FIG. 12 isused. When a graphic object, such as 1200, is selected, then a shape(e.g., 1210) is displayed as the selection, an arbitrary shaperepresenting the graphical object, to provide drag feedback. This isshown for simple objects. As is illustrated in FIGS. 13a and 13b,alternative methods of showing the selection of the graphics and themovement during the drag operation is illustrated. For example, for thegraphic illustrated as 1300 in FIG. 13a, a rectangular shape 1310 may beused to represent the object during the drag. The rectangle is similarin size to the outer bounds of the object being dragged, however, thereis no interior detail shown of the object during the drag. In contrast,as is illustrated in FIG. 13b, the outline of the object and certaininterior details are illustrated in dotted outline form 1360 if graphicobject 1350 is selected and dragged.

Drag Feedback for Text Objects

Two examples, of feedback for the dragging of text objects isillustrated with references to FIGS. 14a and 14b. For example, as shownin FIG. 14a, a selected text region is represented with a dotted outlineof the region, as is illustrated by 1410 in window 1400. Note that thedotted outline is consistent for icons, graphics, and text to providepositive user feedback that a drag is occurring. Similarly, textspanning several lines, such as that shown in FIG. 14b, may be performedusing a dotted outline of the shape of the text as it appears in window1450 by a dotted outline 1460. Examples of the selection of text and themovement thereof within an application program and the positive userfeedback thereof are provided in application Ser. No. 07/632,318 andapplication Ser. No. 07/993,784, which are both assigned to the assigneeof the present invention. Note that there is a distinction between theseselection methods and those used in prior art text selection methodswhich utilize a "I-beam cursor" whenever the cursor is within a textarea, regardless of whether a portion of text is selected. In thecurrent preferred embodiment, the I-beam cursor is not displayed when adrag operation is to be performed, such as the selection (e.g.,mouse-down event) of an item and the movement of three pixels while theregion is selected. An activation and deactivation of the selectiondevice while the cursor is in a window and no movement will result in anI-beam cursor or insertion caret at the place in the text in where theselection was made. This takes place upon the deactivation of theselection device (a mouse-up event). At any rate, the appearance of thedisplay for movements of various types of information will not bediscussed further here, however, the functioning thereof will bediscussed below.

Autoscrolling

Another improved aspect of the user interface display which takes placeduring drag operations is known as "autoscrolling." Autoscrolling is atechnique wherein, during a drag operation or the selection of items fordragging, portions of the window display will "scroll" or move inappearance on the display in order to select additional regions or movethe window to a part in which the window is not currently displayed. Forexample, as is illustrated in FIG. 15a, a user may use cursor 1500 toselect a document and drag that document to another part of the windowor select additional items in the window. The autoscrolling region for awindow is defined as outer border 1510, as is illustrated in 1520 ofFIG. 15b, however, it excludes title bar region 1530 wherein, if thecursor enters that portion of the window, then autoscrolling issuspended. Autoscrolling will scroll in the direction of the portion ofthe scrolling bar selected while the cursor remains at that positionuntil no more scrolling can be performed in the given window. So, if thecursor resides in the right portion of scrolling region 1510, then thewindow scrolls to the right, and if it is at the left portion of thewindow, then the window scrolls to the left.

Autoscrolling is illustrated with reference to FIGS. 15c and 15d. Forexample, a selection of an icon may be performed, as is illustrated inFIG. 15c. The user will drag the icon until it resides in the scroll barregion 1510. In this manner, any areas not currently displayed in awindow may be revealed by placing the cursor on the scroll bar during adrag or range selection operation (e.g., by drawing a rectangle box toselect multiple objects). Thus, the window changes to the appearance, asis illustrated in 1540 of FIG. 15d, by scrolling to the right to revealthe "Files" folder 1560.

Destination Feedback

Another feature provided by the preferred embodiment is destinationfeedback. The user is provided with visual feedback for the destinationwhere the information will be dropped. This is illustrated withreference to FIGS. 16-19b. When dragging takes place, especially intodiscrete windows such as illustrated in FIG. 16, if the window (e.g.,1620) can accept the dragged item, then a single-pixel highlight inset1610 is displayed when the window is the current location of the cursor.Another example is illustrated in FIG. 17. For example, the user may beselecting text 1702 in window 1701 for dragging to a second window 1704.When the cursor enters the region of window 1704, a highlight inset 1710is displayed if the window can receive the dragged information. Thisprovides feedback to the user that information 1702 may be dragged tothat location (the application program controlling 1704 can accept thetext information). While cursor 1700 resides within the domain of window1704, the inset highlighting 1710 is displayed. The preferred embodimentalso provides feedback for subwindows and other user interface objects,such as icons, spreadsheet cells, and other objects which are undercontrol of an application program, have a similar single-pixel insethighlighting to provide additional feedback to the user, even wheninterapplication dragging is taking place. This is illustrated withreference to FIGS. 18aand 18b.

For instance, an electronic mail application may be controlling thewindow shown as 1810 in FIG. 18a. For example, in the electronic mailerwindow 1810 illustrated in FIG. 18a, the user may desire to select suchan item as an electronic mail address to place into "To" field 1820. Inthis instance, when cursor 1800 enters "To" field 1820, then asingle-pixel inset 1825 is displayed within the "To" field to indicatethat that field is capable of receiving the electronic mail addressinformation or other information which is selected and dragged as icon1830. Similarly, as is illustrated in window 1850 of FIG. 18b, selecteddata 1860 may be dropped into the worksheet cell of a spreadsheetdisplayed in window 1850, as is illustrated by the highlighting providedas 1870 in window 1850. In either event, destination highlighting may beprovided for various subwindows, icons, fields, or other discrete userinterface objects in the preferred embodiment when interapplicationdragging is taking place to provide positive feedback to the user. Themechanics of this will be discussed in more detail below with referenceto tracking handlers during the drag and the tracking of the dragthrough various windows or other areas on a computer system display.

Drop Feedback

When the user releases the mouse button after dragging an object to adestination, a "drop" feedback occurs informing that the drag-and-dropoperation was successful. This feedback is visual in the preferredembodiment (but also may be audio, according to an application program'sfunction), and is related to the semantic operation indicated by thedrag-and-drop sequence. Semantics will now be briefly discussed.

Dragging Semantics

Because dragging semantics are intimately related with drop feedback, itwill now be briefly discussed here. Dragging semantics includesappropriate actions which will be performed upon dragging betweenvarious application programs and the main operating system window andvarious other operating system services controlled. The semantics arebriefly summarized with reference to Table 1 below.

                  TABLE 1                                                         ______________________________________                                        Dragging Semantics                                                            To                                                                            Document      File System        Finder                                       From  Same   Different                                                                              Same Volume                                                                            Different Volume                                                                        Service                              ______________________________________                                        Docu- Move   Copy     Copy             Copy                                   ment                                                                          Finder                                                                              Copy        Move       Copy      Copy                                   ______________________________________                                    

Thus, the general role is that, if the window represents a differentitem or location, then the action is interpreted as a copy operation. Inthe case of a same document or same media volume, then it is interpretedas a move operation. Note that, in the cases where the action is indoubt, a copy operation is assumed to avoid any data loss which mayoccur. Thus, for the same document or window in which the data resides,the operation is assumed to be a move operation. Similarly, if it is thesame physical media or same volume, then it is assumed that theoperation is a move. In all other cases, if the windows are different orit is between a document and the Finder or a document in a Finderservice, then the operation is assumed to be a copy operation orperforming the Finder service which the icon or other Finder serviceperforms (e.g., printing, sending electronic mail, etc.).

Finder Icons

When the user drags a document to a folder icon in the Finder, thebehavior of the drop feedback is the reorganization of the document intothe folder; the visual component is the disappearance of the documenticon and the unhighlighting of the destination folder icon (in the caseof a "move" operation).

If an icon represents a system service, such as an electronic mail orprinting, the drop feedback is followed by some indication that theservice is being delivered. For example, if the user drags a document toa printer, the icon would slowly "fill up" in color as the printing jobprogresses towards completion. This is called "progress feedback" and isrepresented using a progress bar or other feedback. One method isillustrated in FIGS. 18c and 18d. For example, as is illustrated in FIG.18c, a progress window 1880 may be displayed upon dropping an item intoa system service such as a printing routine, as was illustrated in FIGS.9a-9d. A progress bar window, such as 1880 shown in FIG. 18c, may bedisplayed first. As is illustrated, progress bar 1890 is currently clearindicating that no printing has yet taken place at this initial stage.In a short time later, however, as illustrated in FIG. 18d, it may havea dark region 1895 which fills up the progress bar indicating thepercentage of completion of the printing job. Other types of systemservice feedback may be provided using various techniques well-known tothose skilled in the art.

Graphics

When dropping graphics, the drop feedback is the movement of the actualobject to the location of the mouse-up event (the release of theselection device), in the preferred embodiment. This was illustrated inFIGS. 6a-6c.

Text

After dropping text, the drop feedback is the movement or copying oftext from the source to the destination, accompanied by a series of"zooming rectangles" from the source text to the destination text in thepreferred embodiment. The zooming rectangles are provided using aroutine ZoomRects( ) described below and are displayed only after thetext is rewrapped because the destination text may end up being adistance away from the exact point where the user dropped the text. If a"move" operation is in effect, the source text disappears. In eithercase, the text is inserted at the destination is selected and may beperformed using the techniques disclosed in Ser. No. 07/993,784 assignedto the assignee of the present invention.

Transferring Selections

After a successful drag-and-drop sequence involving a single window, theselection feedback is transferred from the source to the destination.This is discussed with reference to FIGS. 19a and 19b.

In a single window 1901, as is illustrated in FIG. 19a, selected text1902 may be desired to be moved. As is illustrated in FIG. 19b, text1902 has been moved, and the region remains selected. This process ofcopying between windows is illustrated in FIGS. 19c and 19d.

Background Window Dropping

The results of the process of dragging and dropping into a backgroundwindow is illustrated with reference to FIGS. 19c and 19d. For example,a user may desire to select text (e.g., 1915) in a first window 1910,which is active, and copy that text to a second window 1920, which isnot active (e.g., it may be controlled by an inactive applicationprogram). This can be applied to any type of data being selected,dragged, and dropped between windows. The results of the drag and dropare shown in FIG. 19d. As is illustrated, background window 1920 doesnot become active (e.g., its title bar 1926 is not shown in activestate), and region 1925 is shown in the single-pixel outlinerepresentation surrounding the copied text 1925 from 1915 from window1910. The window is also not brought to the front, in this circumstance.

Abort Feedback

Dropping outside a destination is considered as an "abort" and isindicated in the preferred embodiment by zooming rectangles thatoriginate at the position of the drop and end at the source's location.If, for some reason, dropping inside a destination does not result in asuccessful operation, zooming rectangles are used in the preferredembodiment. This is a form of "negative" drop feedback. This isillustrated with reference to FIGS. 20a-20e.

For example, a user may drag, using cursor 2000, an icon 2020 into asecond window 2002, as is illustrated in FIG. 20a. This is folder 2010which was dragged from window 2001, as is shown by its highlightedstate. Then, as illustrated in FIG. 20b, the abort may be indicated byseries of "zooming rectangles" 2030 generated by the subroutineZoomRects() discussed below. As is illustrated in FIG. 20c, zoomingrectangles head back towards the original folder 2010 until the zoomingrectangles completely disappear from the screen, as shown in FIG. 20d.This is an animated effect indicating to the user that the dragoperation was unsuccessful.

Summary of the Behavior of Windows

Independent Windows

When a window is brought to the front, in the preferred embodiment, onlythat specific window is brought to the front; the entire windowhierarchy belonging to the application is not brought to the front, asin prior art systems. This behavior makes it easier to have a sourcewindow and destination window side-by-side, especially when the twowindows belong to different applications.

Even with this behavior, the user is still able to bring the entirewindow hierarchy belonging to an application to the front. This can bedone in the preferred embodiment by choosing the application's menu itemin an application menu of the user interface display. In the case of theFinder, clicking on the desktop brings the Finder's window hierarchy tothe front. Also, double-clicking on the application's Finder icon bringsthe entire window hierarchy of the application to the front.

Bringing Windows to the Front

In the preferred embodiment, as already been illustrated, the release ofthe selection device (the mouse-up event) serves as theapplication-switching trigger (instead of the mouse-down event as in theprior art), subject to certain exceptions.

If the user clicks inside an inactive window without dragging at leastthree pixels between the mouse-down and mouse-up events (no drag hastaken place), the window is brought to the front. If the user dragswholly inside an inactive window (i.e., the source and destination arein the same inactive window), the window is brought to the front as soonas the mouse-up event occurs. If the user drags from any window toanother window that is inactive, the inactive window is not brought tothe front after the drag-and-drop sequence is completed. If thedrag-and-drop sequence ends at the Finder desktop, no window is broughtto the front. As discussed above, whenever an inactive window is broughtto the front, a background selection (if any) in that window becomeshighlighted as a normal selection, instead of the single-pixel outlinerepresentation.

Drag Verbs

There are three ways in which the user can specify the drag verb that isapplied to a given drag-and-drop sequence. The first way is to performthe drag without holding down any modifier keys. In this case, the mostfrequently used or most likely verb is applied. For example, a printingroutine assumes that a print operation is to take place, and the sendingapplication program and the system service negotiate the type of datatransmitted to allow the information to be printed (see, discussionbelow). The second method is when the user performs the drag whileholding down the Option key. This method specifies the secondary verb.In most cases, this verb would be Copy. However, in cases where Copy isnot applicable, the verb can be something else, such as overriding theconfirmation dialog when dragging an icon from a remote read-only volumeto the desktop. The third way of specifying the drag verb is to holddown the Control key when dragging; as soon as the dragged object isdropped, a verb selection dialog appears, as in FIG. 21. The user canchoose the verb in this dialog, or cancel the operation altogether. Forexample, as is illustrated in FIG. 21, a dialog window 2110 isdisplayed. The user may select, such as using cursor 2100, a selection2102 in verb list 2105. As is typical in standard prior art Macintosh®dialog boxes, the user may either double-click, using cursor 2100 andthe selection device, a selection such as 2102 to cause the verb to beperformed or select "OK" button 2104. To cancel the operation, the userselects "Cancel" button 2103. The list of verbs displayed will be amatch between data item flavors, which are specified by the sendingapplication program, and the service performed by the object at thedestination (e.g., a printing or mail service).

Functional Description

Drag Handlers and Drag Procedures

Application programs supply the Drag Manager callback routines (e.g.,pointers to routines in the program) that the Drag Manager calls toallow the application to implement dragging. The Drag Manager uses twodifferent types of callback routines, called drag handlers and dragprocedures. Drag handlers are routines that are installed on windowsthat the Drag Manager uses when dragging over that window. Dragprocedures are routines that are used by the Drag Manager during a dragregardless of which window the user may be dragging over. The DragManager allows application programs to install the following draghandlers on the program's windows:

a receive data handler that the Drag Manager calls when the userfinishes a drag in one of an application's windows

a drag tracking handler that the Drag Manager calls when the user dragsa selection through one of the application's windows to allow theapplication to track the drag within the window

a constrain mouse handler that the Drag Manager calls when the userdrags a selection through one of the application's windows to allow theapplication to modify the mouse coordinates

The Drag Manager provides a family of InstallHandler and RemoveHandlerroutines that allow an application program to register handlers of eachof these types with the application. An application can register adifferent set of handlers to be used for each window in the application.An application can also register with the Drag Manager a set of handlersto be used when a window does not have its own handlers.

If an application assigns more than one handler of the same type on thesame window, the Drag Manager calls each of these handler routines inthe order that they were installed. This technique is known as"chaining" and allows the control of various areas in a window, such asicons, subwindows, fields, panes, or other user interface objects. FIG.22 shows an example of the tracking handler registry 2200 for anapplication that has installed two handlers 2211 and 2212 for its"Graphics" window 2210, a single handler 2221 for its "Documents" window2220 and a single handler 2231 to be used for all of the application'sother windows. When the Drag Manager 2280 tracks a drag through the"Documents" window, handler 2221 is called. When the Drag Manager tracksa drag through the "Graphics" window, handler 2211 is called followed byhandler 2212 being called. Finally, if the Drag Manager tracks a dragthrough any other window in the application, handler 2231 is called. Forexample, handler 2211 and 2212 may be two distinct tracking handlers,one for the window itself and a second for a specific icon or otherornament within the window. This may be an additional pane for a windowor other type of object within a window. The "Documents" window andother windows which are accessed by the tracking handler registry 2200for this particular application program will have only single trackinghandlers 2221 and 2231, respectively, associated with them for any andall actions within windows in those circumstances.

The second type of callback routine that may be provided to the DragManager is a drag procedure. The Drag Manager uses the following dragprocedures:

a send data procedure that the Drag Manager calls when the receiverapplication requests a drag item flavor that the Drag Manager does notcurrently have the data cached for

a drag input procedure that the Drag Manager calls when sampling themouse position and keyboard state to allow the application program tooverride the current state of the input devices

a drag drawing procedure that if provided by the sender applicationprogram, the Drag Manager calls to allow the sender application toassume responsibility for drawing the drag feedback on the screen

Sending Data

When the user chooses a destination for the items being dragged, thereceiving application program may request from the Drag Manager anynumber of types of data. These various types of data are known, in thepreferred embodiment, as drag item "flavors." Flavors may be of anysort, including ASCII text (flavor type `TEXT`), styled text (`styl`),and rich text (`rtf`). Many other flavors may be used, in the preferredembodiment, according to the data types that the sending and receivingapplication programs understand. Another advantage to the method(s) andapparatus of the preferred embodiment is that sending applicationprograms may provide data in addition to flavors. This is done if thereis sufficient time available to provide the data in addition to theflavor. If the sending application program provided the flavor's data tothe Drag Manager when calling one of the AddFlavor routines, the DragManager will simply provide that data to the receiver.

The application program may have chosen not to provide the data to theDrag Manager when calling one of the AddFlavor routines because it mighthave taken too long to prepare the data (and, perhaps, cause auser-perceivable performance penalty), or there might not have beenenough memory to store the data. In this case, the Drag Manager callsthe DragSendProc (if one was given to the Drag Manager) to allow thesending application to provide the data to the Drag Manager only whenneeded by the receiver, and the flavors provided act as "promises" whichmay be fulfilled at such time that the receiver requests the data.

If the sending application only exports small pieces of data that areeasily generated, the data would presumably by provided when calling theAddFlavor routines discussed below and therefore the sender applicationwould not need to provide a DragSendProc.

Receiving Data

When the user drops a collection of items in one of a receivingapplication's windows, the Drag Manager calls all of theReceiveDropHandler routines that are installed on the destinationwindow. This call allows the program to request the drag item flavorsthat the receiving application wishes to accept.

The receiver application program can inspect the available flavors byusing the CountDragItems, GetItemReferenceNumber, CountDragItemFlavors,GetFlavorType, GetFlavorFlags and GetFlavorData functions which aredescribed in more detail below. It receives flavor from the senderapplication by calling the GetFlavorData function. The GetFlavorDatafunction calls the sender's SendDataProc if necessary to get the datafor the receiver.

Drag Tracking

While the user drags a collection of items on the screen, as the mousepasses through one application's windows, the Drag Manager calls theDragTrackingHandler routines that are installed on the window under themouse to allow the application program to track the drag through itswindows. For example, this allows the highlight or other drag feedbackto take place, as discussed below with reference to FIGS. 16-18b.

The Drag Manager sends the application's DragTrackingHandler trackingstatus messages as the user moves the mouse. The DragTrackingHandlerreceives the following messages from the Drag Manager:

an enter handler message when the focus of a drag enters a window thatis handled by an application's DragTrackingHandler from any window thatis not handled by the same DragTrackingHandler

an enter window message when the focus of a drag enters any window thatis handled by an application's DragTrackingHandler

an in window message as the user drags within a window handled by theapplication's DragTrackingHandler

a leave window message when the focus of a drag leaves any window thatis handled by an application's DragTrackingHandler

a leave handler message when the focus of a drag enters a window that isnot handled by an application's DragTrackingHandler

When an application's handler receives any of these messages from theDrag Manager, it can use the CountDragItems, GetItemReferenceNumber,CountDragItemFlavors, GetFIavorType and GetFlavorFlags routines toinspect the drag item flavors that are contained in the drag todetermine if the application program should highlight its window or aportion of its window.

The in window message can be used to highlight specific containerswithin a window or if window contains a text field, an insertion pointwithin the text field.

The enter window and leave window messages occur in pairs. Thesemessages are useful for highlighting a window that can accept the itemsbeing dragged.

The enter handler and leave handler messages also occur in pairs. Thesemessages only occur when the drag moves between windows that are handledby different routines. These messages are useful for allocating andreleasing memory that the application might need when tracking within aspecific set of windows.

FIG. 23 shows an example of a user dragging a clippings file from aFinder window 2310 through two windows 2320 and 2330 of a wordprocessing application. The following example demonstrates what trackingmessages are sent to the Finder's tracking handler and an applicationrequested by icon 2311 during a drag:

Cursor 2300 at position 2350--The user dicks and drags on the clippingsfile and the Finder starts a drag. The Finder receives an enter handlermessage followed by an enter window message. As the user drags withinthe Finder's "Clippings" window, the Finder receives multiple in windowmessages.

Cursor 2300 at position 2360--When the user drags into the wordprocessor's "Untitled 1" window, the Finder receives a leave windowmessage followed by a leave handler message. The word processingapplication then receives an enter handler message followed by an enterwindow message. While the user drags within the application's "Untitled1" window 2320, the application program receives in window messages.

Cursor 2300 at position 2370--Assuming that both of the word processor'swindows 2320 and 2330 are handled by the same DragTrackingHandler, whenthe user drags into the "Sample Text" window, the word processingapplication receives a leave window message followed by an enter windowmessage. It does not receive any enter/leave handler messages since thesame handler routine is used for both windows. As the user drags withinthe application's "Sample Text" window 2330, the application receives inwindow messages.

Cursor 2300 at position 2380--When the user releases the selectiondevice when the cursor is at position 2380, the data transaction occurs.Then the word processing application receives a leave window messagefollowed by a leave handler message. Drag tracking is now complete.

Using the Drag Manager

The Drag Manager allows the user to drag items in and out of a window orother object controlled by an application program. Before items can bedragged into or out of a window, the application program must register aset of drag handlers for the Drag Manager to use when the application isinvolved in dragging. A drag and drop action by the user is broken downinto three discrete steps. The steps are first to pick up the item oritems being dragged, then to track the selection being dragged throughapplication windows as the user searches for a place to drop theselection, and finally to then drop the item or items at the user'schosen destination.

This section explains in detail how the Drag Manager is used to:

install and remove drag handlers to and from the Drag Manager's handlerregistry for the application's windows

prepare the Drag Manager with drag items and drag item flavors

start a drag process

track a drag through the application's windows

send data to the receiver of a drag that originated from anapplication's windows

request and receive data flavors from the sender application when theuser drops the selection within an application's windows

Installing and Removing Drag Handlers

A drag handler is registered with the Drag Manager using theInstallHandler functions. There is a separate InstallHandler functionfor each kind of handler. These functions are InstallReceiveHandler,InstallTrackingHandler and InstallConstrainHandler.

Each of the InstallHandler functions takes a pointer to a window thatthe application wants to associate the handler with. If NIL is suppliedas the window pointer, the Drag Manager will register the handler in thespecial area that is used when a drag occurs in a window that is notregistered with the Drag Manager. Handlers installed in this specialarea are called default handlers.

A reference constant may be passed to each of the InstallHandlerfunctions. This value is stored by the Drag Manager and is forwarded toeach handler's routine when it is called.

The following code segment shows how to use the InstallHandler functionsto install a default handler for the application:

    ______________________________________                                        OSErr MyInitDragManager ()                                                     { OSErr result;                                                               if (result = InstallReceiveHandler(MyDefaultReceiveHandler,                      NIL, &myGlobals)) {                                                         return(result);                                                              }                                                                             return(InstallTrackingHandler(MyDefaultTrackingHandler,                          NIL, &myGlobals));                                                        ______________________________________                                    

The function MyInitDragManager calls InstallReceiveHandler andInstallTrackingHandler to install default receive and tracking handlersfor the application program. In the window parameter, NIL is passed tospecify that these handlers should be installed as default handlers. Apointer to the application's global variables is passed in the referenceconstant parameter.

The following shows how to use the InstallHandler functions to installhandlers for a specific window:

    ______________________________________                                        OSErr MyDoNewWindow (WindowPtr *newWindow)                                    { OSErr result;                                                                WindowPtr theWindow;                                                          if (|(theWindow = GetNewWindow(kMyWindowID, 0L, -1L))) {                       return(resNotFound);                                                         }                                                                             if (result = InstallReceiveHandler(MyReceiveHandler,                             theWindow, &myGlobals)) {                                                   DisposeWindow(theWindow);                                                     return(result);                                                              }                                                                             if (result = InstallTrackingHandler(MyTrackingHandler,                           theWindow, &myGlobals)) {                                                   DisposeWindow(theWindow);                                                     return(result);                                                              }                                                                             *newWindow = theWindow;                                                       return(noErr) ;                                                              ______________________________________                                    

The function MyDoNewWindow calls all three of the InstallHandlerfunctions to install a set of drag handlers for the window that itcreates. In DoNewWindow, the window pointer is passed to theInstallHandler functions.

In the scenario created in the last two example functions, the DragManager will use the MyReceiveHandler and MyTrackingHandler functionswhen the focus of a drag occurs within any window created with theDoNewWindow function. Any other windows in the application would use theMyDefaultReceiveHandler and the MyDefaultTrackingHandler functions.

To remove a drag handler from the Drag Manager's handler registry, theRemoveHandler functions are used. The following shows how to remove draghandlers:

    ______________________________________                                        OSErr MyDoCloseWindow(WindowPtr theWindow)                                     RemoveReceiveHandler(MyReceiveHandler, theWindow);                            RemoveTrackingHandler(MyTrackingHandler, theWindow);                          DisposeWindow(theWindow);                                                     return(noErr);                                                               }                                                                             ______________________________________                                    

The function MyDoCloseWindow demonstrates the use of the RemoveHandlerfunctions. The same routine address and window pointer is used to removea handler. If NIL is used as the window pointer, the Drag Manager willattempt to remove the handler from the default handler registry.

Beginning a Drag

When the user clicks on an item or a selection of items in anapplication and begins to move the mouse without first releasing themouse button, the user is making a gesture to begin dragging theselected objects.

To start a drag, a new drag reference is created by calling the NewDragfunction. The NewDrag function returns a reference number that theapplication uses to refer to a specific drag process in subsequentfunction calls to the Drag Manager.

After creating a new drag reference, drag item flavors can be added tothe drag by calling the Drag Manager's AddFlavor functions.

When all of the data describing the items contained in the drag has beengiven to the Drag Manager, the application calls TrackDrag to actuallybegin the drag. The following code segments show how mouse down eventsand start drag operations are handled.

    ______________________________________                                        OSErr MyDoMouseDown(EventRecord *theEvent)                                    { OSErr result = noErr;                                                        short thePart;                                                                WindowPtr theWindow;                                                          Boolean onItem;                                                               thePart = FindWindow(theEvent->where, &theWindow);                            switch(thePart) {                                                              case inContent:                                                                if (theWindow == FrontWindow()) {                                              MyDoContentClick(theEvent, theWindow, &onItem);                               if (onItem && WaitMouseMoved(theEvent)) {                                      result = MyDoStartDrag(theEvent, theWindow);                                 }                                                                            } else {                                                                       SelectWindow(theWindow);                                                     }                                                                            case ...                                                                     }                                                                             return(result);                                                              ______________________________________                                    

The function MyDoMouseDown above shows a simplified mouse down eventservice routine. Only the code for handling an inContent part code fromFindWindow is shown. The MyDoContentClick function either selects,extends the selection or deselects an item in the application's documentwindow. The onItem parameter it returns is true if the mouse down eventoccurred on a draggable item. The routine then calls WaitMouseMoved,which is a Drag Manager function that waits for the mouse button to bereleased or the mouse to move from its mouse down location. It returnstrue if the mouse moved. The MyDoStartDrag function, which is listedbelow, is called if the user gestures to start a drag.

    ______________________________________                                        OSErr MyDoStartDrag(EventRecord *theEvent, WindowPtr theWindow)               { OSErr result;                                                                DragReference theDrag;                                                        if(result = NewDrag(&theDrag, (long) theWindow)) {                             return(result);                                                              }                                                                             if (result = MyDoAddFlavors(theWindow, theDrag)) {                             DisposeDrag(theDrag);                                                         return(result);                                                              }                                                                             return(TrackDrag(theDrag));                                                  ______________________________________                                    

The MyDoStartDrag function above first creates a new drag by calling theNewDrag function. It then calls the MyDoAddFlavors function, which isdefined below, to add the application's drag item flavors to the drag.Finally, TrackDrag is called to perform the drag.

To add drag item flavors to a drag, the AddFlavor functions are used.The AddFlavor functions require a drag reference number to add theflavor to. The application program also provides an item referencenumber when adding flavors. The handlers may specify any item referencenumbers when adding items. The same item number is used for addingflavors to the same drag item. Using a different item number results ina new item being created.

    ______________________________________                                        OSErr MyDoAddFlavors(WindowPtr theWindow, DragReference                       theDrag)                                                                      { MyDocumentItem *theItem;                                                     theItem = GetFirstSelectedItem(theWindow);                                    while (theItem) {                                                              AddDragItemFlavor(theDrag, theItem, `MOOF`,                                     (Ptr) *(theItem->dataHandle),                                                 GetHandleSize(theItem->dataHandle), 0);                                     AddDragItemFlavor(theDrag, theItem, `TEXT`, (Ptr) 0L, 0L, 0);                 if (theItem->hasStyles) {                                                      AddDragItemFlavor(theDrag, theItem, `styl`, (Ptr) 0L, 0L, 0);                }                                                                             AddDragRegionFlavor(theDrag, theItem, theItem->region);                       theItem = theItem->nextSelectedItem;                                         }                                                                            ______________________________________                                    

The MyDoAddFlavors function shown above uses the Drag Manager'sAddFlavor functions to add three or four flavors to the drag for eachitem that is selected in the window.

The first call to AddDragItemFlavor uses the document item pointer asthe drag item reference number. Since this is the first flavor added tothe drag, a new drag item is created with that item number. The firstflavor for the item is the application's own internal data type `MOOF`.A pointer to the data and the data's size is also passed to theAddDragItemFlavor function.

The second call to AddDragItemFlavor uses the same document item pointeras the drag item reference number. Since this is the same item number asthe last call, the second flavor is added to the same drag item. Thisflavor is of type `TEXT`. Suppose that an application does not want tocreate the plain text data unless this flavor is specifically requestedby the receiver of a drag. A NIL pointer and zero size is passed toAddDragItemFlavor. By passing NIL, the Drag Manager will call thisapplication DragSendProc to get the data later, if needed.

In this example, an item in the selection may have text styles (such asbold or italic characters), and if it does, it also adds a `styl`flavor. Again, the same item number is used to add the flavor to thesame drag item. The flavor data is not provided; it will only be createdif needed.

Finally, AddDragRegionFlavor is called to add the item's drag region tothe item. This region is given in global coordinates. The Drag Manageruses this region to drag the dotted outline of the drag on the screen.The receiver may want to get the region to determine where to place thecontents of the item.

The MyDoAddFlavors function loops to the next selected item in its list.When it adds the flavors for the next item, it will be using a differentitem number (since the address of the next item is guaranteed to bedifferent), which will result in a new drag item being created.

To illustrate the effect of calling the MyDoAddFlavors function definedabove, FIGS. 24 and 25 show an example list of selected items and theresulting drag items and drag item flavors.

For example, as each item is selected, it is added to a linked list, asis illustrated by 2400 in FIGS. 24. For example, as each item in windowsare selected, drag items are acted to a selected item list, such as 2400illustrated in FIGS. 24. As each item is selected, a datum is added,such as 2410, 2420, and 2430, to the selected item list 2400. Each itemcontains four fields, each representing different portions of the itembeing selected. A first field (e.g., 2410a, 2420a, and 2430a) containsan integer representing a reference drag item number. A second field(e.g., 2410b, 2420b, and 2430b) contains the actual item information,which is shown in more detail below with reference to FIG. 25. 2410ccontains an integer value representing a number of styles which areadded in addition to a specific flavor of type `TEXT`. As shown, only2430c has a value that is non-zero, indicating that one additionalflavor type is promised by the sending process. 2410d, 2420d, and 2430deach contain references to the next drag item in the list with the lastdrag item pointer 2430d containing the pointer NIL indicating that noother drag items are being dragged and tracked by the Drag Manager.

A more detailed view of the drag items in a drag item list, such as2500, is illustrated in FIG. 25. For example, drag item 2410b containsthree flavors, `MOOF` 2561, `TEXT` 2562, and `drgn` 2563. Because theapplication was able to create flavor data 2561a of type `MOOF,` field2561 contains a flavor data field 2561a. The data type of type `TEXT`was not able to be created at the time of the drag, so a DragSendProcwould need to be invoked in order for the sending application to providethat data to the receiver. Lastly, 2563 contains a drag region so thatthe Drag Manager may keep track and provide visual feedback to the userof the dotted drag item region while the drag is taking place across theuser interface display. This flavor data is provided in field 2563a,which is a bitmap representation of the item as created by the sendingapplication program's handler. Similarly, drag items 2420b and 2430bcontain similar fields, with the exception that drag item 2430b containsan additional flavor type of type `styl` in field 2583, which might bemade available to the receiving application upon the detection of therelease of the selection device (e.g., a mouse-up event), as detected bythe Drag Manager.

The Drag Manager also provides two additional AddFlavor routines. Theyare AddHFSFlavor, which adds an HFSFlavor record given an FSSpec record,and AddAEFlavor, which adds the data contained within an AEDesc record,using the descriptor's data type as the flavor type.

Tracking a Drag

After creating a new drag with NewDrag, adding drag item flavors to thedrag by using the AddFlavor functions, and starting the drag withTrackDrag, the Drag Manager proceeds by tracking the drag until the userreleases the mouse button.

During the drag, as the user moves the mouse on the screen, searchingfor a destination for the drag items, the Drag Manager sends a sequenceof tracking messages to the tracking handlers that are registered forthe window that the mouse is over.

A tracking handler can inspect the drag item flavors contained in a dragand highlight the application's windows or part of an application'swindows in response to data that the application can accept.

The next code segment shows an example of a very simple trackinghandler. This tracking handler highlights the window if any of the dragitems contains either the application's `MOOF` flavor or the `TEXT`flavor. It also calls an application defined functionMyTrackItemUnderMouse that could be defined to highlight other pans ofthe window as the mouse moves through the window.

    __________________________________________________________________________    OSErr MyTrackingHandler(short theMessage, Point mouse, WindowPtr              theWindow,                                                                    GlobalsPtr myGlobals, DragReference theDrag)                                  switch(theMessage) {                                                          case kDragEnterHandlerMessage:                                                myGlobals-->canAcceptDrag = IsMyTypeAvailable(theDrag);                       break;                                                                        case kDragEnterWindowMessage:                                                 if (myGlobals-->canAcceptDrag) {                                                      ShowDragHilite(theDrag,                                                         ((WindowPeek) theWindow)-->contRgn, true);                          }                                                                             break;                                                                        case kDragInWindowMessage:                                                    if (myGlobals-->canAcceptDrag) {                                                      MyTrackItemUnderMouse(mouse, theWindow);                              }                                                                             break;                                                                        case kDragLeaveWindowMessage:                                                 if (myGlobals-->canAcceptDrag) {                                                      HideDragHilite(theDrag);                                              }                                                                             break;                                                                        case kDragLeaveHandlerMessage:                                                myGlobals-->canAcceptDrag = false;                                            break;                                                                        }                                                                             }                                                                             __________________________________________________________________________

The MyTrackingHandler function defined above switches on the givenmessage from the Drag Manager. If the message iskDragEnterHandlerMessage, the routine calls the application'sIsMyTypeAvailable function, which is defined below, that returns eithertrue or false, depending on whether or not a type is available that theapplication window can accept. The result of this function is stored inthe application's global variable canAcceptDrag.

When MyTrackingHandler received the kDragEnterWindowMessage message, itchecks its global canAcceptDrag to determine if the window can acceptthe drag. If it can, the Drag Manager utility function ShowDragHilite iscalled to highlight the window.

When the kDragInWindowMessage message is received, if the window canaccept the drag, the application's MyTrackItemUnderMouse is called.Presumably, MyTrackItemUnderMouse would use the mouse coordinate givenby the Drag Manager to determine if the mouse is over an object thatmust also be highlighted.

When the kDragLeaveWindowMessage message is received, if the window canaccept the drag, the Drag Manager utility function HideDragHilite iscalled to remove the window highlighting.

Finally, when the kDragLeaveHandlerMessage message is received, theapplication's global canAcceptDrag is reset to false.

To determine what drag item flavors are available, an application callsroutines in the Drag Manager known as CountDragItems,GetItemReferenceNumber, CountDragItemFlavors, GetFlavorType andGetFlavorFlags functions to determine how many drag items there are,return an item's reference number (e.g., stored in field 2410a),determine how many drag item flavors there are in a drag item, return adrag item flavor's type (e.g., stored in flavor 2561), and the flagsidentifying the attributes of a flavor.

The next code segment shows the IsMyTypeAvailable function whichdemonstrates the use of these functions.

    __________________________________________________________________________    Boolean IsMyTypeAvailable(DragReference theDrag)                              { short  items, index, result;                                                  long   flavorFlags;                                                           ItemReference                                                                        itemID;                                                              CountDragItems(theDrag, &items);                                              for (index= 1; index<= items; index++) {                                      GetItemReferenceNumber(theDrag, index, &itemID);                              result = GetFlavorFlags(theDrag, itemID, `MOOF`, &flavorFlags);               if ((result == noErr) && (flavorFlags & kFlavorAvailable))                    return(true);                                                                 result = GetFlavorFlags(theDrag, itemID, `TEXT`, &flavorFlags);               if ((result == noErr) && (flavorFlags & kFlavorAvailable))                    return(true);                                                                 return(false);                                                                }                                                                             __________________________________________________________________________

The IsMyTypeAvailable function defined above counts the number of itemsin the drag and begins a loop through each of the items. It returns truewhen it encounters the first item that contains either a `MOOF` flavoror a `TEXT` flavor, which are types (flavors) that this receiver canhandle. The IsMyTypeAvailable function was used to determine if theapplication should highlight its window. In this manner, arbitration maybe performed between sending and receiving handlers to test to determineif a type that the receiving application can receive.

After the user releases the mouse button, the Drag Manager proceeded tothe data transaction stage to the finish the drag.

Finishing a Drag

When the user has chosen a final destination for the items beingdragged, the Drag Manager calls any receive drop handlers installed onthe destination window. An application program's receive drop handler isresponsible for accepting the drag by transferring the information beingdragged into the destination location.

A receive handler gets a pointer to the destination window, thehandler's reference constant and the drag reference. The receive handlerroutine can call the CountDragItems, GetItemReferenceNumber,CountDragItemFlavors, GetFlavorType and GetFlavorFLags functions todetermine what data types (flavors) are included in the drag. TheGetFlavorData function can be used to get flavor data from the senderthat the receiver application desires.

The next code segment shows an example receive handler that attempts toreceive a `MOOF` type and if available inserts it into the destinationfile's data and then on the display. If there is no `MOOF` flavor in theitem, the handler checks to see if a `TEXT` type is available. If `TEXT`is available in the item, the handler gets the `TEXT` data and then alsochecks to see if a `styl` type is available. If `styl` is available, thehandler get the `styl` data also. The handler inserts the `TEXT` dataand optionally the `styl` data into the destination file's data and thenon the display.

    __________________________________________________________________________    pascal OSErr MyReceiveHandler(WindowPtr theWindow, unsigned long              handlerRefCon,                                                                DragReference theDrag)                                                        { Point  mouse;                                                                 short  items, index, result;                                                  long   flavorFlags, dataSize, stylSize;                                       ItemReference                                                                        itemID;                                                                Ptr    theData, theStyl;                                                    DragGetMouse(&mouse, OL, theDrag);                                            CountDragItems(theDrag, &items);                                              for (index = 1; index <= items; index++) {                                    GetItemReferenceNumber(theDrag, index, &itemID);                              //                                                                            //    First try to get type `MOOF`                                            //                                                                            result = GetFlavorFlags(theDrag, itemID, `MOOF`, &flavorFlags);               if ((result == noErr) && (flavorFlags & kFlavorAvailable)) {                  // Determine the size of the `MOOF` data                                      dataSize = 0;                                                                 GetFlavorData(theDrag, itemID, `MOOF`, 0L, &dataSize, 0L);                    // Allocate space for the `MOOF` data                                         theData = NewPtr(dataSize);                                                   // Get the `MOOF` data                                                        GetFlavorData(theDrag, itemID, `MOOF`, theData, &dataSize, 0L);               // Put the data into the destination location                                 MyInsertDataAtPosition(theData, dataSize, mouse, theWindow);                  DisposePtr(theData);                                                          } else {                                                                      //                                                                            //      Since there is no `MOOF` type in the drag, try to get                 //      `TEXT` and possibly `styl`.                                           //                                                                            result = GetFlavorFlags(theDrag, itemID, `TEST`, &flavorFlags);               if ((result == noErr) && (flavorFlags & kFlavorAvailable)) {                          // Determine the size of the `TEXT` data                                      dataSize = 0;                                                                 GetFlavorData(theDrag, itemID, `TEXT`, 0L, &dataSize, 0L);                    // Allocate space for the `TEXT` data                                         theData = NewPtr(dataSize);                                                   // Get the `TEXT` data                                                        GetFlavorData(theDrag, itemID, `TEXT`, theData, &dataSize, 0L);               // Check for `styl` to accompany `TEXT`                                       theStyl = 0L;                                                                 result = GetFlavorFlags(theDrag, itemID, `styl`, &flavorFlags);                 if (result == noErr) && (flavorFlags & kFlavorAvailable)) {                   // Determine the size of the `styl` data                                      stylSize = 0;                                                                 GetFlavorData(theDrag, itemID, `styl`, 0L, &stylSize, 0L);                    // Allocate space for the `styl` data                                         theData = NewPtr(stylSize);                                                   // Get the `styl` data                                                        GetFlavorData(theDrag, itemID, `styl`, theStyl,                                   &stylSize, 0L);                                                         }                                                                             MyInsertStylTextAtPoint(theData, dataSize, theStyl, stylSize,                         mouse, theWindow);                                                    DisposePtr(theData);                                                          if (theStyl)                                                                    DisposePtr(theStyl);                                                }                                                                             }                                                                             return(noErr);                                                                }                                                                             __________________________________________________________________________

If the receiver of a drag requests a flavor, and if the sendingapplication provided the flavor data to the Drag Manager when adding theflavor with one of the AddFlavor functions, the Drag Manager simplyprovides the data to the receiver.

If the sender did not provide the flavor data to the Drag Manager whenadding the flavor, the Drag Manager calls the sender's DragSendProc toallow the sending application program to provide the data to the DragManager on demand.

The Drag Manager calls the DragSendProc with the requested flavor type,an optional acceptorDescriptor parameter, the handler's referenceconstant, and the item and drag reference numbers. TheSetDragItemFlavorData function is used to provide the requested data tothe Drag Manager in the DragSendProc.

    __________________________________________________________________________    pascal OSErr MySendDataProc(FlavorType theType, const AEDesc                  *acceptorDescriptor,                                                          unsigned long refCon, ItemReference theItem,                                  DragReference theDrag)                                                        { OSErr                                                                              result;                                                                  Document                                                                           *theDocument = (Document *) theItem;                                   if (theType == `TEXT`) {                                                      SetDragItemFlavorData(theDrag, theItem, `TEXT`,                               MyGetSelectedTextPtr(theDocument),                                            MyGetSelectedTextSize(theDocument));                                          } else if (theType == `styl`) {                                               SetDragItemFlavorData(theDrag, theItem, `styl`,                               MyGetSelectedStylPtr(theDocument),                                            MyGetSelectedStylSize(theDocument));                                          } else {                                                                      return(badDragFlavorErr);                                                     return(noErr);                                                                }                                                                             __________________________________________________________________________

The MySendDataProc function shown above provides both the `TEXT` and`styl` flavors to the Drag Manager. The routine uses the item referencenumber as a pointer to the application's Document data structure (thispointer was used when adding the drag item flavors withAddDragItemFlavor). This example routine calls several of its ownroutines that would presumably return the memory addresses and datasizes of both the selected text and the `styl` data. The Drag Manager'sSetDragItemFlavorData function is called to pass the requested data tothe Drag Manager.

Drag Manager Variables and Routines

This section describes the Drag Manager's constants, data structures androutines.

The "Constants" section describes the constants received from the DragManager and used when calling Drag Manager routines. The "DataStructures" section shows the data structures used to refer to drags,drag items, drag item flavors and to special drag item flavor data. The"Drag Manager Routines" section describes Drag Manager routines forinstalling and removing drag handlers, creating and disposing of dragreferences, adding drag item flavors to a drag, providing drag callbackroutines, tracking a drag, getting drag item information, getting dragstatus information, window highlighting and Drag Manager relatedutilities. The "Application-Defined Routines" section describes the draghandler functions, the drag callback functions and the zoom callbackfunction.

Constants

The constants described in this section are received from the DragManager and used when calling Drag Manager routines.

Flavor Flags

The following constants are used to provide additional attributeinformation about drag item flavors. These constants are used whencalling the AddFlavor functions and can be obtained using theGetFlavorFlags function.

    ______________________________________                                        #define kFlavorAvailable                                                                           1                                                        #define kFlavorSenderOnly                                                                          2                                                        #define kFlavorSenderTranslated                                                                    4                                                        #define kFlavorTMTranslated                                                                        8                                                        ______________________________________                                    

Constant Descriptions

kFlavorAvailable--Set if the flavor is available to the receiver of adrag.

kFlavorSenderOnly--Set if the flavor is only available to the sender ofa drag. The flavor is visible only if the receiver is the sameapplication as the sender.

kFlavorSenderTranslated--Set if the flavor data is translated by thesender. This attribute is useful if the receiver needs to determine ifthe sender is performing its own translation to generate this data type.

kFlavorTMTranslated--Set if the flavor data is provided by theTranslation Manager. The Translation Manager is a second system servicewhich is called during all drag operations and provides additionalflavors and data, if needed, upon the performance of a drop bytranslating some flavor from the sender to one that the receiver canunderstand. In short, the Translation Manager adds flavors stored in thedrag item and arbitrates between sender and receiver handlers at droptime where the data is translated. So, the sender makes promises aboutdata in the form of flavors and so does the Translation Manager. If aflavor is requested by the receiver that only the Translation Managercan provide, then a translation is performed at drop time, and thereceiver is notified when the data is ready to be received. Translationof data is provided in the manner provided in application Ser. No.07/984,180, which is assigned to the assignee of the present invention.Although that application describes translation of files, thetranslation of discrete packets of data is performed in a similarmanner. If this flavor is requested, the Drag Manager will obtain therequired data type from the sender and then it will use the TranslationManager to provide the data that the receiver requested.

Drag Attributes

The following constants are used to provide additional attributeinformation about a drag that is in progress. The attribute flagsprovide information about the window and application that the drag iscurrently occurring in.

    ______________________________________                                        #define kDragHasLeftSourceWindow                                                                    1                                                       #define kDragIsInSourceApplication                                                                  2                                                       #define kDragIsInSourceWindow                                                                       4                                                       ______________________________________                                    

Constant Descriptions

kDragHasLeftSourceWindow--Set if the drag has not left the source windowsince the beginning of the drag. This flag is useful for providingwindow highlighting after the user has moved the mouse outside of thesource window.

kDragIsInSourceApplication--Set if the drag is currently in any windowthat belongs to the application that started the drag.

kDragIsInSourceWindow--Set if the drag is currently in the same windowthat the drag started from.

Special Flavor Kinds

The following constants are used to identify special flavor kinds thatare defined by the Drag Manager.

    ______________________________________                                        #define kDragRegionFlavorKind                                                                          `drgn`                                               #define kHFSFlavorKind   `hfs`                                                ______________________________________                                    

Constant Descriptions

kDragRegionFlavorKind--The flavor kind for a drag region flavor. TheDrag Manager uses drag region flavors to determine the shape of eachdrag item being dragged. The drag region flavor data is a region inglobal coordinates of the item being dragged (for example, s used in theApple brand QuickDraw graphics routines). Drag region flavors arecreated by calling the AddDragRegionFlavor function.

kHFSFlavorKind--The flavor kind for an HFS (Hierarchical Filing System)file system object (e.g., a file being dragged). The Finder uses HFSflavors when dragging file system objects. The HFS flavor data isdefined by the HFSFlavor structure defined below. HFS flavors arecreated by calling the AddHFSFlavor function.

Zoom Acceleration

The following constants are used when specifying a zoomAccelerationconstant to either the ZoomRects or ZoomRegion functions.

    ______________________________________                                        #define kZoomNoAccelerate                                                                         0                                                         #define kZoomAccelerate                                                                           1                                                         #define kZoomDecelerate                                                                           2                                                         ______________________________________                                    

Constant Descriptions

kZoomNoAccelerate--Linear interpolation is used for each frame ofanimation between the source and destination.

kZoomAccelerate--Increment the step size for each frame of animationbetween the source and destination. This option produces the visualappearance of the animation speeding up as it approaches thedestination.

kZoomDecelerate--Decrement the step size for each frame of animationbetween the source and destination. This option produces the visualappearance of the animation slowing down as it approaches thedestination.

Data Structures

This section describes the data structures that are called to identifydrags, drag items, drag item flavors and special drag item flavor databy application programs.

Drag Reference

The Drag Reference is a reference to a drag object. Before calling anyother Drag Manager routine, a new Drag Reference must be first createdby calling the NewDrag function. The Drag Reference that is returned byNewDrag is used in all subsequent calls to the Drag Manager. TheDisposeDrag function is used to dispose of a Drag Reference after it isfinished being used.

typedef unsigned long DragReference;

Drag Item Reference

The Drag Item Reference is a reference number used to refer to a singleitem in a drag. Drag Item Reference numbers are created by the senderapplication when adding drag item flavor information to a drag. DragItem Reference numbers are created by and are only be interpreted by thesender application.

typedef unsigned long ItemReference;

Flavor Type

The Flavor Type is a four character type that describes the format ofdrag item flavor data. The Flavor Type has the same function as a scraptype; it designates the format of the associated data. Any scrap type,resource type or even AppleEvent brand descriptor type may be used.

Four character types consisting of only lower-case letters are reservedby Apple. A unique type can be guaranteed by using the registeredapplication signature.

typedef ResType FlavorType;

HFS Drag Item Flavor Record

The Drag Manager defines a special data flavor for dragging fie systemobjects. The HFS (Hierarchical Filing System) drag item flavor is usedwhen dragging documents (e.g., files) and folder (e.g., directory) iconsin the Finder. The HFS drag item flavor record is defined by theHFSFlavor data type.

An HFS drag item flavor is added to a drag by the sending applicationprogram by using the AddHFSFlavor function.

    ______________________________________                                        typedef struct HFSFlavor {                                                    OSType      fileType;  // file type                                           OSType      fileCreator;                                                                             // file creator                                        unsigned short                                                                            fdFlags;   // Finder flags                                        FSSpec      fileSpec;  // file system specification                           } HFSFlavor;                                                                  ______________________________________                                    

Field Descriptions

fileType--The file type of the object.

fileCreator--The file creator of the object.

fdFlags--The Finder flags of the object (Finder flags are defined in the"Finder Interface" chapter of the publication "Inside Macintosh").

fileSpec--The FSSpec record for the object.

Drag Manager Routines

This section describes the Drag Manager routines are used to start adrag from an application program, gain control when the user drags anobject into one of the application's windows, support the drag and dropuser interface and to send and receive data as part of a droptransaction.

Installing and Removing Drag Handler Routines

The Drag Manager is called to install or remove handler routines for anentire application program or for one of an application program'swindows. The Drag Manager provides a pair of install/remove functionsfor each handler type.

InstallTrackingHandler

The InstallTrackingHandler function is used to install a trackinghandler routine for the Drag Manager to use while the user drags throughan application's windows. The tracking handler provides feedback inwindows controlled by the application program.

    ______________________________________                                        pascal OSErr InstallTrackingHandler                                                    (DragTrackingHandler theTrackingHandler,                                      WindowPtr theWindow,                                                          unsigned long handlerRefCon);                                        ______________________________________                                    

theTrackingHandler--Pointer to a DragTrackingHandler routine.

theWindow--A pointer to the window to install the drag tracking handlerfor. When the cursor moves into this window during a drag, the DragManager sends tracking messages to the application program's handlerroutine. If this parameter is NIL, the given handler will be installedin the default handler space for the application (the handler is activefor all windows in the application).

handlerRefCon--A reference constant that will be forwarded to theapplication program's drag tracking handler routine when it is called bythe Drag Manager.

The InstallTrackingHandler function installs a tracking handler for oneof the application's windows. Installing a tracking handler allows theapplication to track the user's movements through the application'swindows during a drag. More than one drag tracking handler may beinstalled on a single window.

The Drag Manager sequentially calls all of the drag tracking handlersinstalled on a window when the user moves the cursor over that windowduring a drag.

By specifying a value of NIL in theWindow, the tracking handler isinstalled in the default handler space for the application. Dragtracking handlers installed in this way are called when the user movesthe mouse over any window that belongs to the application.

Multiple drag handler routines of the same kind may be installed for thesame window to determine if subwindows, etc. may handle the datapromised in the drag item(s) and handle highlighting of destinations,such as subwindows, etc., to provide feedback to the user. Each draghandler routine will be called in the chain until a handler handles therequested task.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr        0           No error                                             paramErr     -50         Parameter error                                      memFullErr   -108        Not enough memory                                    handlerExistsErr                                                                           -1860       Handler already exists                               ______________________________________                                    

InstallReceiveHandler

The InstallReceiveHandler function is used to install a receive drophandler routine for the Drag Manager to use when the user releases themouse button while dragging over one of the application's windows. Thisroutine will allow data to be accepted by the destination application.

    ______________________________________                                        pascal OSErr InstallReceiveHandler                                                     (ReceiveDropHandler theReceiveHandler,                                        WindowPtr theWindow,                                                          unsigned long handlerRefCon);                                        ______________________________________                                    

theReceiveHandler--Pointer to a ReceiveDropHandler routine.

theWindow--A pointer to the window to install the receive drop handlerfor.

When a drop occurs over (e.g., mouseUp event following a drag) thiswindow, the Drag Manager calls this routine to allow the application toaccept the drag. If this parameter is NIL, the given handler will beinstalled in the default handler space for the application (the handlerwill be called if a drop occurs in any window in the application).

handlerRefCon--A reference constant that will be forwarded to theapplication program's receive drop handler routine when it is called bythe Drag Manager.

The InstallReceiveHandler function installs a receive drop handler forone of the application's windows. Installing a receive handler allowsthe application to accept a drag by getting drag item flavor data fromthe Drag Manager when the user releases the mouse button while draggingover one of the application's windows. More than one receive drophandler may be installed on a single window.

The application program may install multiple drag handler routines ofthe same kind for the same window to allow multiple subwindows, etc. inthe application to receive data. Each drag handler routine in the chainwill be called until a handler handles the requested task.

The Drag Manager sequentially calls all of the receive drop handlersinstalled on a window when a drop occurs in that window until a handlerhandles the requested task.

By specifying a value of NIL in theWindow, the receive drop handler isinstalled in the default handler space for the application. Receive drophandlers installed in this way are called when a drop occurs in anywindow that belongs to the application.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr        0           No error                                             paramErr     -50         Parameter error                                      memFullErr   -108        Not enough memory                                    handlerExistsErr                                                                           -1860       Handler already exists                               ______________________________________                                    

InstallConstrainHandler

The InstallConstrainHandler function is used to install a constrainmouse handler routine for the Drag Manager to use when the user releasesthe mouse button while dragging over one of the application's windows.

    ______________________________________                                        pascal OSErr InstallConstrainHandler                                                   (DragConstrainHandler theConstrainHandler,                                    WindowPtr theWindow,                                                          unsigned long handlerRefCon);                                        ______________________________________                                    

theConstrainHandler--Pointer to a DragConstrainHandler routine.

theWindow--A pointer to the window to install the constrain mousehandler for. When the cursor is over this window, the Drag Manager callsthis routine to allow the mouse coordinates to be constrained by theapplication. If this parameter is NIL, the given handler will beinstalled in the default handler space for the application (the handlerwill be called for all windows in the application).

handlerRefCon--A reference constant that will be forwarded to theapplication program's constrain mouse handler routine when it is calledby the Drag Manager.

The InstallConstrainHandler function installs a constrain mouse handlerfor one of the application's windows. Installing a constrain mousehandler allows the application to constrain the dragging movement to anydegree of freedom that a user chooses (such as horizontal, vertical orgrid movement). More than one constrain mouse handler may be installedon a single window.

The Drag Manager sequentially calls all of the constrain mouse handlersinstalled on a window when the user moves the cursor over that windowduring a drag.

By specifying a value of NIL in theWindow, the constrain mouse handleris installed in the default handler space for the application. Constrainmouse handlers installed in this way are called when the user moves themouse over any window that belongs to the application.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr        0           No error                                             paramErr     -50         Parameter error                                      memFullErr   -108        Not enough memory                                    handlerExistsErr                                                                           -1860       Handler already exists                               ______________________________________                                    

RemoveTrackingHandler

The RemoveTrackingHandler function is used to remove a tracking handlerroutine from one of the application's windows.

    ______________________________________                                        pascal OSErr RemoveTrackingHandler                                                     (DragTrackingHandler theTrackingHandler,                                      Windowptr theWindow);                                                ______________________________________                                    

theTrackingHandler--Pointer to a DragTrackingHandler routine.

theWindow--A pointer to the window to remove the drag tracking handlerfrom. If this parameter is NIL, the given handler will be removed fromthe default handler space for the application.

The RemoveTrackingHandler function removes a drag tracking handler fromone of the application's windows.

By specifying a value of NIL in theWindow, the tracking handler isremoved from the default handler space for the application (e.g., thechain).

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0          No error                                                paramErr   -50        Parameter error                                         memFullErr -108       Not enough memory                                       handlerNotFoundErr                                                                       -1861      Drag handler could not he found                         ______________________________________                                    

RemoveReceiveHandler

The RemoveReceiveHandler function is used to remove a receive drophandler routine from one of the application's windows.

    ______________________________________                                        pascal OSErr RemoveReceiveHandler                                                      (ReceiveDropHandler theReceiveHandler,                                        WindowPtr theWindow);                                                ______________________________________                                    

theReceiveHandler--Pointer to a ReceiveDropHandler routine.

theWindow-A pointer to the window to remove the receive drop handlerfrom. If this parameter is NIL, the given handler will be removed fromthe default handler space for the application.

The RemoveReceiveHandler function removes a receive drop handler fromone of the application's windows.

By specifying a value of NIL in theWindow, the receive drop handler isremoved from the default handler space for the application.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr       0         No error                                                paramErr    -50       Parameter error                                         memFullErr  -108      Not enough memory                                       handlerNotFound                                                                           -1861     Drag handler could not be found                         ______________________________________                                    

RemoveConstrainHandler

The RemoveConstrainHandler function is used to remove a constrain mousehandler routine from one of the application's windows.

    ______________________________________                                        pascal OSErr RemoveConstrainHandler                                                    (DragConstrainHandler theConstrainHandler,                                    WindowPtr theWindow);                                                ______________________________________                                    

theConstrainHandler--Pointer to a DragConstrainHandler routine.

theWindow--A pointer to the window to remove the constrain mouse handlerfrom. If this parameter is NIL, the given handler will be removed fromthe default handler space for the application.

The RemoveConstraintHandler function removes a constrain mouse handlerfrom one of the application's windows.

By specifying a value of NIL in theWindow, the constrain mouse handleris removed from the default handler space for the application.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0          No error                                                paramErr   -50        Parameter error                                         memFullErr -108       Not enough memory                                       handlerNotFoundErr                                                                       -1861      Drag handler could not be found                         ______________________________________                                    

Creating and Disposing of Drag References

A drag reference is created whenever an application wishes to start adrag. The drag reference is a token that used in all subsequent calls toDrag Manager routines to refer to a particular drag.

NewDrag

The NewDrag function is used to create a new drag reference token.

    ______________________________________                                        pascal OSErr NewDrag (DragReference *theDragRef,                                       unsigned long senderRefCon);                                         ______________________________________                                    

theDragRef--The drag reference, which NewDrag fills in before returning.

senderRefCon--A reference constant that will be forwarded to anapplication program's drag handler routines when they are called by theDrag Manager. This constant is used to pass any data that is wished tobe forwarded to the application program's handler routines.

The NewDrag function allocates a drag object in the Drag Manager andreturns a drag reference token in the theDrag parameter. This dragreference is used in subsequent calls to the Drag Manager to identifythe drag. This drag reference is required when adding drag item flavorsand calling TrackDrag. All of the application program's installed draghandlers receive this drag reference so other Drag Manager routines canbe called within the application program's drag handlers.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr       0            No error                                             paramErr    -50          Parameter error                                      memFullErr  -108         Not enough memory                                    ______________________________________                                    

DisposeDrag

The DisposeDrag function is used to dispose of a drag reference tokenand its associated data when a drag has been completed or if the drag isno longer needed.

pascal OSErr DisposeDrag (DragReference theDragRef);

theDragRef--The drag reference of the drag object to dispose of.

The DisposeDrag function disposes of the drag object that is identifiedby the given drag reference token. If the drag reference contains dragitem flavors, the memory associated with the drag item flavors isdisposed of as well.

DisposeDrag should be called after a drag has been performed usingTrackDrag or if a drag reference was created but is no longer needed.

    ______________________________________                                        Result codes:                                                                 ______________________________________                                        noErr       0           No error                                              paramErr    -50         Parameter error                                       badDragRefErr                                                                             -1851       Unknown drag reference                                dragInUseErr                                                                              -1853       Drag reference is in use                              ______________________________________                                    

Providing Drag Callback Procedures

Drag callback procedures are provided to the Drag Manager when a userwants to override the default behavior of the Drag Manager. A user canoverride the mechanisms in the Drag Manager that provide data to a dropreceiver, that samples the mouse and keyboard and that draws thestandard "dotted outline" drag feedback.

SetDragSendProc

The SetDragSendProc function is used to set the send data procedure forthe Drag Manager to use with a particular drag.

    ______________________________________                                        pascal OSErr SetDragSendProc                                                                    (DragReference theDragRef,                                                    DragSendDataProc theSendProc,                                                 unsigned long theRefCon);                                   ______________________________________                                    

theDragRef--The drag reference that SetDragSendProc will set the dragsend procedure for.

theSendProc--The send data routine that will be called by the DragManager when the receiver of a drop requests the flavor data of a flavorthat has not been cached by the Drag Manager.

theRefCon--A reference constant that will be forwarded to theapplication program's drag send procedure when it is called by the DragManager. This constant is used to pass any data that is wished to beforwarded to the application program's drag send procedure.

The SetDragSendProc function sets the drag send procedure for the givendrag reference. A drag's drag send procedure is called by the DragManager when the receiver of a drop requests the data of a flavor andthe requested flavor data is not currently cached by the Drag Manager.

The Drag Manager caches drag item flavor data when the flavor was addedto a drag by calling AddDragItemFlavor. If NIL is passed toAddDragItemFlavor as the data pointer, the flavor data is not cached andthe Drag Manager will attempt to cache the data by calling the drag sendprocedure.

A drag send procedure is not needed if the application never passes NILto AddDragItemFlavor when adding a drag item flavor to a drag.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0              No error                                            paramErr   -50            Parameter error                                     ______________________________________                                    

SetDragInputProc

The SetDragInputProc function is used to set the drag input procedurefor the Drag Manager to use with a particular drag.

    ______________________________________                                        pascal OSErr SetDragInputProc                                                                    (DragReference theDragRef,                                                    DragInputProc theInputProc,                                                   unsigned long theRefCon);                                  ______________________________________                                    

theDragRef--The drag reference that SetDragInputProc will set the draginput procedure for.

theInputProc--The drag input routine that will be called by the DragManager whenever the Drag Manager requires the location of the mouse,the state of the mouse button and the status of the modifier keys.

theRefCon--A reference constant that will be forwarded to theapplication program's drag input procedure when it is called by the DragManager. This constant is used to pass any data that is to be forwardedto the application program's drag input procedure.

The SetDragInputProc function sets the drag input procedure for thegiven drag reference. A drag's drag input procedure is called by theDrag Manager whenever the Drag Manager requires the location of themouse, the state of the mouse button and the status of the modifier keyson the keyboard. The Drag Manager typically calls this routine once percycle through the Drag Manager's main drag tracking loop.

The application program's drag input procedure may either modify thecurrent state of the mouse and keyboard to slightly alter draggingbehavior or entirely replace the input data to drive the drag completelyby itself.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0              No error                                            paramErr   -50            Parameter error                                     ______________________________________                                    

SetDragDrawingProc

The SetDragDrawingProc function is used to set the drag drawingprocedure for the Drag Manager to use with a particular drag.

    ______________________________________                                        pascal OSErr SetDragDrawingProc                                                                (DragReference theDragRef,                                                    DragDrawingProc theDrawingProc,                                               unsigned long theRefCon);                                    ______________________________________                                    

theDragRef--The drag reference that SetDragDrawingProc will set the dragdrawing procedure for.

theDrawingProc--

The drag drawing routine that will be called by the Drag Manager todraw, move and hide the "dotted outline" drag feedback on the screenduring a drag.

theRefCon--A reference constant that will be forwarded to theapplication program's drag drawing procedure when it is called by theDrag Manager. This constant is used to pass any data that is wished tobe forwarded to the application program's drag drawing procedure.

The SetDragDrawingProc function sets the drag drawing procedure for thegiven drag reference. A drag's drag drawing procedure is called by theDrag Manager when the Drag Manager needs to draw, move or hide the"dotted outline" drag feedback on the screen.

The application program's drag drawing procedure can implement any typeof drag feedback, such as dragging a bitmap of the object being dragged.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0              No error                                            paramErr   -50            Parameter error                                     ______________________________________                                    

Adding Drag Item Flavors

The set of AddFlavor routines can be used to create drag items and toprovide the data types for each item. Special AddFlavor routines can beused to add FSSpec flavors and to add the data contained within AEDescrecords.

AddDragItemFlavor

The AddDragItemFlavor function is used to create drag items and to add adata flavor to a drag item.

    ______________________________________                                        pascal OSErr AddDragItemFlavor                                                                   (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     FlavorType theType,                                                           Ptr data,                                                                     unsigned long dataSize                                                        short flavorFlags);                                        ______________________________________                                    

theDragRef--A drag reference.

theItemRef--The drag item reference to add the flavor to. New drag itemsare created by providing unique item reference numbers (e.g., thosestored in fields 2561, 2562, etc. in FIG. 25). By using the same itemreference number as in a previous call to AddDragItemFlavor, the flavoris added to an existing item. Any item reference number may be used whenadding flavors to items.

theType--The data type of the flavor to add. This may be anyfour-character scrap, resource or AppleEvent type. The application'ssignature is used for a unique type for the application's own internaluse.

data--A pointer to the flavor data.

dataSize--The size, in bytes, of the flavor data.

flavorFlags--A set of attributes to set for this flavor.

The AddDragItemFlavor function adds a drag item flavor to a drag item. Anew drag item is created if the given item reference number is differentthan any other item reference numbers. When adding multiple flavors tothe same item, supply the same item reference number.

In many cases it is easiest to use index numbers as item referencenumbers (1, 2, 3 . . . ). Item reference numbers are only used as unique"key" numbers for each item. Item reference numbers do not need to begiven in order nor must they be sequential. Depending on theapplication, it might be easier to use the user's own internal memoryaddresses as item reference numbers (as long as each item being draggedhas a unique item reference number).

Sometimes it is useful to defer the creation of a particular data typeuntil a receiver has specifically requested it (possibly if a lengthytranslation is required). This can be done by passing NIL in the dataparameter when adding a drag item flavor. Flavors that are added in thisway will cause the Drag Manager to call the drag's send data procedureif the flavor is requested to get the data from the application.

All of the drag item flavors must be added to a drag before callingTrackDrag. Once TrackDrag is called, AddDragItemFlavor will returncantAddNewFlavorErr when attempting to add flavors to a drag that is inprogress.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr         0          No                                                   paramErr      -50        Parameter error                                      memFullErr    -108       Not enough memory                                    badDragRefErr -1851      Unknown drag reference                               flavorExistsErr                                                                             -1857      Flavor already exists                                cantAddNewFlavorErr                                                                         -1858      Cannot add new flavor                                                         (drag is in progress)                                ______________________________________                                    

AddHFSFlavor

The AddHFSFlavor function is used to add an HFS (Hierarchical FilingSystem) drag item flavor to a drag.

    ______________________________________                                        pascal OSErr AddHFSFlavor                                                                        (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     FSSpec *fileSpec,                                                             unsigned long flavorFlags);                                ______________________________________                                    

theDragRef--A drag reference.

theItemRef--The item reference to add the flavor to. A new item iscreated when a new item reference is given. By using the same itemreference as a previously added flavor, the flavor is added to the sameitem.

fileSpec--A file system specification.

flavorFlags--A set of attributes to set for this flavor.

The AddHFSFlavor function adds an HFS (Hierarchical Filing System)flavor to the specified item within the given drag reference.AddHFSFlavor creates a HFSFlavor data structure and fills thestructure's fields by calling FSpGetFInfo and then callsAddDragItemFlavor to add a flavor of type `hfs`.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr       0       No error                                                  nsvErr      -35     No such Volume                                            ioErr       -36     I/O error                                                 bdNamErr    -37     Bad filename                                              fnfErr      -43     File not found                                            paramErr    -50     No default volume                                         memFullErr  -108    Not enough memory                                         dirNFErr    -120    Directory not found or                                                        incomplete pathname                                       badDragRefErr                                                                             -1851   Unknown drag reference                                    flavorExistsErr                                                                           -1857   Flavor already exists                                     cantAddNewFlavorErr                                                                       -1858   Cannot add new flavor                                                         (drag is in progress)                                     afpAccessDenied                                                                           -5000   User does not have the correct access                     afpObjectTypeErr                                                                          -5025   Directory not found or                                                        incomplete pathname                                       ______________________________________                                    

AddAEFlavor

The AddAEFlavor function is used to add an AppleEvent descriptor as adrag item flavor.

    ______________________________________                                        pascal OSErr AddAEFlavor                                                                        (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     AEDesc theAEDesc,                                                             unsigned long flavorFlags);                                 ______________________________________                                    

theDragRef--A drag reference.

theItemRef--The item reference to add the flavor to. A new item iscreated when a new item reference is given. By using the same itemreference as a previously added flavor, the flavor is added to the sameitem.

fiIeSpec--An AppleEvent descriptor.

flavorFlags--A set of attributes to set for this flavor.

The AddAEFlavor function takes an AppleEvent descriptor record and addsa drag item flavor of the descriptor type containing the descriptorrecord's data.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr         0          No error                                             paramErr      -50        Parameter error                                      memFullErr    -108       Not enough memory                                    badDragRefErr -1851      Unknown drag reference                               flavorExistsErr                                                                             -1857      Flavor already exists                                cantAddNewFlavorErr                                                                         -1858      Cannot add new flavor                                                         (drag is in progress)                                ______________________________________                                    

AddDragRegionFlavor

The AddDragRegionFlavor function is used to add a drag region flavor toa drag item.

    ______________________________________                                        pascal OSErr AddDragRegionFlavor                                                                 (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     RgnHandle theRgn);                                         ______________________________________                                    

theDragRef--A drag reference.

theItemRef--The item reference to add the flavor to. A new item iscreated when a new item reference is given. By using the same itemreference as a previously added flavor, the flavor is added to the sameitem.

theRgn--A region in global coordinates that is the outline of the dragitem. The AddDragRegionFlavor function adds a drag region flavor to adrag item. The Drag Manager uses an item's drag region flavor to drawthe "dotted outline" drag feedback for an item being dragged.

Every drag item should be given a drag region flavor. Without the dragregion flavor, the Drag Manager is able to render the item on the screenduring a drag.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr        0        No error                                                paramErr     -50      No default volume                                       memFullErr   -108     Not enough memory                                       badDragRefErr                                                                              -1851    Unknown drag reference                                  flavorExistsErr                                                                            -1857    Flavor already exists                                   cantAddNewFlavorErr                                                                        -1858    Cannot add new flavor (drag is in                                             progress)                                               ______________________________________                                    

SetDragItemFlavorData

The SetDragItemFlavorData function is used to set the data containedwithin an existing flavor.

    ______________________________________                                        pascal OSErr SetDragItemFlavorData                                                               (DragReference theDragRef,                                                   ItemReference theItemRef,                                                     FlavorType theType,                                                           Ptr data,                                                                     unsigned long dataSize);                                    ______________________________________                                    

theDragRef--A drag reference.

theItemRef--A drag item reference of the item that contains the flavor auser wishes to set the data for.

theType--The data type of the existing flavor to set the data for.

data--A pointer to the flavor data.

dataSize--The size, in bytes, of the flavor data.

The SetDragItemFlavorData function sets a given flavor's data. Data thatwas previously contained within a flavor is completely replaced by thedata in the given data buffer.

This function is commonly used in a scenario where a flavor's data isnot added to the flavor when the flavor is created usingAddDragItemFlavor. Only after the drop receiver specifically requeststhe flavor is it necessary to provide the data using theSetDragItemFlavorData routine. This method is useful when the data needsto be translated by the sender and would be to expensive to compute thedata until absolutely required.

This function, unlike the AddFlavor functions, may be called by anapplication's handler during a drag.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr   -50      Parameter error                                           memFullErr -108     Not enough memory                                         badDragRefErr                                                                            -1851    Drag reference is unknown or invalid                      badItemRefErr                                                                            -1852    Item reference is unknown or invalid                      badDragFlavorErr                                                                         -1855    Drag flavor is unknown                                    ______________________________________                                    

Performing a Drag

The TrackDrag function can be used to track a drag from within theapplication.

TrackDrag

The TrackDrag function is used to drag an object or collection ofobjects from the application.

    ______________________________________                                        pascal OSErr TrackDrag                                                                         (const EventRecord *theEvent,                                                  DragReference theDragRef);                                  ______________________________________                                    

theEvent--The mouseDown event record that the application received thatresulted in starting a drag.

theDragRef--A drag reference token to perform the drag operation with.

The TrackDrag function performs a drag operation given the mouseDownevent and a drag reference token.

The Drag Manager follows the cursor on the screen with the "dottedoutline" drag feedback and sends tracking messages to applications thathave registered drag tracking handlers. The drag item flavor informationthat was added to the drag using the AddDragItemFlavor functions isavailable to each application that becomes active during a drag.

When the user releases the mouse button, the Drag Manager calls anyreceive drop handlers that have been registered on the destinationwindow. An application's receive drop handler(s) are responsible foraccepting the drag and transferring the dragged data into theirapplication.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0       No error                                                   paramErr   -50     Parameter error                                            dragInUseErr                                                                             -1853   Drag reference is in use (already dragging)                dragInProgressErr                                                                        -1854   Cannot start drag (a drag is in progress)                  ______________________________________                                    

Getting Drag Item Information

The Drag Manager provides a set of functions that allows a user to getinformation about the drag items and drag item flavors that have beenadded into a drag reference.

CountDragItems

The CountDragItems function is used to determine how many drag items arecontained in a drag reference. This is used to obtain a particular dragitem.

    ______________________________________                                        pascal OSErr CountDragItems                                                                     (DragReference theDragRef,                                                     unsigned short *numItems);                                 ______________________________________                                    

theDragRef--A drag reference.

numItems--The CountDragItems function returns the number of drag itemsin the given drag reference in the numItems parameter.

The CountDragItems function returns the number of drag items in a dragreference in the numItems parameter.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr   -50      Parameter error                                           badDragRefErr                                                                            -1851    Drag reference is unknown or invalid                      ______________________________________                                    

GetItemReferenceNumber

The GetItemReferenceNumber function is used to determine the itemreference number of a specific item in a drag reference.

    ______________________________________                                        pascal OSErr GetItemReferenceNumber                                                              (DragReference theDragRef,                                                     unsigned short index,                                                         ItemReference *theItemRef);                               ______________________________________                                    

theDragRef--A drag reference.

index--The index of an item in a drag reference to get the itemreference number of.

theItemRef--The GetItemReferenceNumber function returns the itemreference number of the item with the specified index in the theItemRefparameter.

The GetItemReferenceNumber function returns the item reference number ofthe item with the specified index in the theItemRef parameter.

If index is zero or larger than the number of items in the drag,paramErr is returned by GetItemReferenceNumber.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr   -50      Parameter error                                           badDragRefErr                                                                            -1851    Drag reference is unknown or invalid                      ______________________________________                                    

CountDragItemFlavors

The CountDragItemFlavors function is used to determine how many dragitem flavors are contained in a drag item in a drag reference. This isused to obtain a particular drag item by a handler.

    ______________________________________                                        pascal OSErr CountDragItemFlavors                                                                (DragReference theDragRef,                                                     ItemReference theItemRef,                                                     unsigned short *numFlavors);                              ______________________________________                                    

theDragRef--A drag reference.

theItemRef--An item reference number.

numFlavors--The CountDragItemFlavors function returns the number of dragitem flavors in the specified drag item in the numFlavors parameter.

The CountDragItemFlavors function returns the number of drag itemflavors in the specified drag item in the numFlavors parameter.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr   -50      Parameter error                                           badDragRefErr                                                                            -1851    Drag reference is unknown or invalid                      badItemRefErr                                                                            -1852    Item reference is unknown or invalid                      ______________________________________                                    

GetFlavorType

The GetFlavorType function is used to determine the type of a specificflavor in a drag item.

    ______________________________________                                        pascal OSErr GetFlavorType                                                                      (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     unsigned short index,                                                         FlavorType *theType);                                       ______________________________________                                    

theDragRef--A drag reference.

theItemRef--An item reference number.

index--The index of a flavor in the specified item to get the type of.

theType--The GetFlavorType function returns the type of the specifiedflavor in the theType parameter.

The GetFlavorType function returns the type of the specified flavor inthe theType parameter.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr        0      No error                                                  paramErr    -50     Parameter error                                           badDragRefErr                                                                            -1851    Drag reference is unknown or invalid                      badItemRefErr                                                                            -1852    Item reference is unknown or invalid                      badDragFlavorErr                                                                         -1855    Drag flavor is unknown                                    ______________________________________                                    

GetFlavorFlags

The GetFlavorFlags function is used to determine the attributes of aspecific flavor in a drag item. This is used to determine if anapplication can accept a dragged item.

    ______________________________________                                        pascal OSErr GetFlavorFlags                                                                     (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     FlavorType theType,                                                           unsigned long *flavorFlags);                                ______________________________________                                    

theDragRef--A drag reference.

theItemRef--An item reference number.

theType--The flavor type of the flavor to get the attributes of.

flavorFlags--The GetFlavorFlags function returns the attributes of thespecified flavor in the flavorFlags parameter.

The GetFlavorFlags function returns the attributes of the specifiedflavor in the flavorFlags parameter.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr        0      No error                                                  paramErr    -50     Parameter error                                           badDragRefErr                                                                            -1851    Drag reference is unknown or invalid                      badItemRefErr                                                                            -1852    Item reference is unknown or invalid                      badDragFlavorErr                                                                         -1855    Drag flavor is unknown                                    ______________________________________                                    

GetFlavorData

The GetFlavorData function is used to get the flavor data for a specificflavor in a drag item. This obtains the data for a specified flavor.

    ______________________________________                                        pascal OSErr GetFlavorData                                                                      (DragReference theDragRef,                                                    ItemReference theItemRef,                                                     FlavorType theType,                                                           Ptr dataBuf,                                                                  unsigned long *dataSize,                                                      AEDesc *acceptorDescriptor);                                ______________________________________                                    

theDragRef--A drag reference.

theItemRef--An item reference number.

theType--The flavor type of the flavor to get the flavor data from.

dataBuf--Specifies where the GetFlavorData function should copy therequested flavor data. The application is responsible for allocating thememory for the flavor data and for setting the dataSize parameter to thenumber of bytes that has been allocated for the data. If the dataBufparameter points to an area of memory that is not large enough to holdall the data contained in the specified flavor, GetFlavorData returns asmuch data as the specified buffer memory area can hold, returns theamount of data remaining in the dataSize parameter, and returns theresult code dragBufferIsSmallErr.

dataSize--Contains the size of the data (in bytes) pointed to by thedataBuf parameter. If GetFlavorData returns the result codedragBufferIsSmallErr, the dataSize parameter contains the number ofbytes remaining. GetFlavorData can be called again to receive the restof the data.

acceptorDescriptor--An optional AppleEvent description of the droplocation that will be forwarded to the send data procedure that will beproviding the requested flavor data.

The GetFlavorData function returns a flavor's data in a data buffersupplied by the application.

A buffer can be allocated to hold the flavor data and pass the number ofallocated bytes to the GetFlavorData function. GetFlavorData will returnthat number of bytes of data and update the dataSize parameter to theamount of data bytes remaining in the flavor.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr         0     No error                                                  paramErr     -50    Parameter error                                           badDragRefErr                                                                             -1851   Drag reference is unknown or invalid                      badItemRefErr                                                                             -1852   Item reference is unknown or invalid                      badDragFlavorErr                                                                          -1855   Drag flavor is unknown                                    dragBufferIsSmallErr                                                                      -1856   Specified buffer is too small to receive                                      data                                                      cantGetFlavorErr                                                                          -1859   Error while trying to get flavor data                     ______________________________________                                    

Getting Drag Status Information

The Drag Manager provides a set of functions that allows a user to getinformation about a drag that is currently in progress.

DragGetFlags

The DragGetFlags function is used to get the current set of dragattribute flags.

    ______________________________________                                        pascal OSErr DragGetFlags                                                                       (unsigned long *dragFlags,                                                    DragReference theDragRef);                                  ______________________________________                                    

dragFlags--The DragGetFlags function returns the drag attribute flagsfor the given drag reference in the dragFlags parameter.

theDragRef--A drag reference.

The DragGetFlags function returns the drag attribute flags for the givendrag reference in the dragFlags parameter.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr  -50       Parameter error                                           badDragRefErr                                                                          -1851      Drag reference is unknown or invalid                      ______________________________________                                    

DragGetMouse

The DragGetMouse function is used to get the current mouse and pinnedmouse locations. This is used to determine whether given areas in awindow should be highlighted.

    ______________________________________                                        pascal OSErr DragGetMouse                                                                       (Point *mouse,                                                                Point *pinnedMouse,                                                           DragReference theDragRef);                                  ______________________________________                                    

mouse--The DragGetMouse function returns the mouse location in the mouseparameter. The mouse location is given in global screen coordinates.

pinnedMouse--The DragGetMouse function returns the pinned mouse locationin the pinnedMouse parameter. The pinned mouse location is the mouselocation that is being used to draw the "dotted outline" drag region inits current location. The pinnedMouse location is different than themouse location only when the cursor approaches the edge of the screenand the drag region is "pinned" to the edge of the screen. The pinnedmouse location is given in global screen coordinates.

theDragRef--A drag reference.

The DragGetMouse function returns the mouse location in the mouseparameter and the pinned mouse location in the pinnedMouse parameter.All coordinates are given in global screen coordinates.

NIL may be passed into the mouse or pinnedMouse parameters if a userwishes to disregard either of these return values.

Calling DragGetMouse before using the drag in a TrackDrag call returns(0, 0) as both the mouse and pinnedMouse locations.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr  -50       Parameter error                                           badDragRefErr                                                                          -1851      Drag reference is unknown or invalid                      ______________________________________                                    

DragGetModifiers

The DragGetModifiers function is used to get the current set of keyboardmodifiers.

    ______________________________________                                        pascal OSErr DragGetModifiers                                                                    (short *modifiers,                                                            short *mouseDownModifiers,                                                    short *mouseupModifiers,                                                      DragReference theDragRef);                                 ______________________________________                                    

modifiers--The DragGetModifiers function returns the current keyboardmodifiers in the modifiers parameter.

mouseDownModifiers--The DragGetModifiers function returns the keyboardmodifiers at mouseDown time in the mouseDownModifiers parameter.

mouseUpModifiers--The DragGetModifiers function returns the keyboardmodifiers at the time of a mouseUp event in the mouseUpModifiersparameter.

theDragRef--A drag reference.

The DragGetModifiers function returns the set of modifier keys at thecurrent time, at mouseDown time and at mouseUp time.

NIL may be passed into the modifiers, mouseDownModifiers ormouseUpModifiers parameters if a user wishes to disregard any of thesereturn values.

NIL may be passed into any of the modifier parameters if a user wishesto disregard any of the return values of that parameter.

Calling DragGetModifiers before using the drag in a TrackDrag callreturns zero in all of the modifier parameters. Calling DragGetModifiersduring a drag, but while the drag is still tracking returns zero in themouseUpModifiers parameter.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0        No error                                                  paramErr  -50       Parameter error                                           badDragRefErr                                                                          -1851      Drag reference is unknown or invalid                      ______________________________________                                    

Window Highlighting Utilities

ShowDragHilite, HideDragHilite, and UpdateDragHilite functions can beused to highlight parts of the application's windows during a drag. TheDragPreScroll and DragPostScroll functions can also be used if a userintends to scroll parts of the window that contain drag highlighting.

ShowDragHilite

The ShowDragHilite function is used to highlight an area of the windowduring a drag. The application program's tracking handler routine shouldcall this if a drop is allowed at the current mouse position.

    ______________________________________                                        pascal OSErr ShowDragHilite                                                                    (DragReference theDragRef,                                                    RgnHandle hiliteFrame,                                                        Boolean inside);                                             ______________________________________                                    

theDragRef--The drag reference of the drag currently in progress.

frame--A region of the frame of the window, pane, or shape a user wishesto highlight. This region should be in the window's local coordinatesystem.

inside--If true, the highlighting will be drawn inside the frame shape.Otherwise it will be drawn outside the frame shape. Note that in eithercase, the highlight will not include the boundary edge of the frame.

The ShowDragHilite procedure creates a standard drag and drop highlightin the window. Only one highlight can be shown at a time, and if thisroutine is called when a highlight is currently visible, the first oneis removed before the newly requested highlight is shown.

The highlight that is drawn is defined by the hiliteFrame and insideparameters. The hiliteFrame is the defining region for the highlight,which is made by creating a two pixel outline either inset or outsetfrom the region. The inside parameter determines whether the pixeloutline is drawn on the inside of the region (if true), or outside ofthe region (if false). This allows easy highlighting inside a windowframe or a pane, or to highlight outside of a container or object in thewindow.

ShowDragHilite assumes that the highlighting should be drawn in thecurrent port. The application makes sure that the correct port is setbefore calling ShowDragHilite. Also, highlighting drawn byShowDragHilite is clipped to the current port. Make sure that the port'sclip region is appropriately sized to draw the highlighting.

The Drag Manager maintains the currently highlighted portion of thewindow if the HideDragHilite and UpdateDragHilite functions are used. Ifit is intended to scroll the window that contains the highlighting, theDragPreScroll and DragPostScroll functions can be used to properlyupdate the drag highlighting. This is required because a scroll causesparts of frame highlighting to be eliminated.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0           No error                                               paramErr   -50         Parameter error                                        memFullErr -108        Not enough memory                                      badDragRefErr                                                                            -1851       Unknown drag reference                                 dragHiliteErr                                                                            -1870       Highlight is invalid                                   ______________________________________                                    

HideDragHilite

This routine removes highlighting created with the ShowDragHilitefunction.

pascal OSErr HideDragHilite (DragReference theDragRef);

theDragRef--The drag reference that is currently showing a draghighlight.

The HideDragHilite function is used to remove any highlighting from thewindow that was shown using the ShowDragHilite function.

HideDragHilite assumes that the highlighting should be erased from thecurrent port. The application should make sure that the correct port isset before calling HideDragHilite. Also, highlighting erased byHideDragHilite is clipped to the current port.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0           No error                                               badDragRefErr                                                                            -1851       Unknown drag reference                                 dragHiliteErr                                                                            -1870       Highlight is invalid                                   ______________________________________                                    

DragPreScroll

When scrolling part of the window when drag highlighting is showing, theDragPreScroll function is used to remove any drag highlighting thatwould be scrolled away from the hiliteFrame given to ShowDragHilite.

    ______________________________________                                        pascal OSErr DragPreScroll                                                                     (DragReference theDragRef,                                                    short dH,                                                                     short dV);                                                   ______________________________________                                    

theDragRef--The drag reference.

dH--The horizontal distance intended to be scroll.

dV--The vertical distance intended to be scroll.

The DragPreScroll function prepares the window or pane for scrolling.This function is used if scroll part of the window using ScrollRect orCopyBits is planned.

Scrolling part of the window may inadvertently move part of the draghighlighting with it. DragPreScroll is optimized to remove from thescreen only the parts of the highlighting that will be scrolled awayfrom the hiliteFrame region. After calling DragPreScroll with the dH anddV that will be scrolled, a user can then scroll the window followed bya call to DragPostScroll which redraws any necessary highlighting afterthe scroll. The details of this procedure are discussed below.

If an offscreen port is used to draw the window into while scrolling,the HideDragHilite and ShowDragHilite functions should be used topreserve drag highlighting in the off screen port. The DragScrollfunctions are optimized for onscreen scrolling.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0           No error                                               paramErr   -50         Parameter error                                        memFullErr -108        Not enough memory                                      badDragRefErr                                                                            -1851       Unknown drag reference                                 dragHiliteErr                                                                            -1870       Highlight is invalid                                   ______________________________________                                    

DragPostScroll

The DragPostScroll function is used to restore the drag highlight afterscrolling part of the window using the DragPreScroll function.

pascal OSErr DragPostScroll (DragReference theDragRef);

theDragRef--The drag reference.

The DragPostScroll function restores the drag highlight after scrollingpart of the window. This routine must be called following a call toDragPreScroll.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0           No error                                               paramErr   -50         Parameter error                                        memFullErr -108        Not enough memory                                      badDragRefErr                                                                            -1851       Unknown drag reference                                 dragHiliteErr                                                                            -1870       Highlight is invalid                                   ______________________________________                                    

UpdateDragHilite

The UpdateDragHilite function is used to update a portion of the draghighlight that was drawn over by the application.

    ______________________________________                                        pascal OSErr UpdateDragHilite                                                                   (DragReference theDragRef,                                                    RgnHandle updateRgn);                                       ______________________________________                                    

theDragRef--The drag reference.

updateRgn--A region that needs to be updated. Typically the port'supdateRgn.

The UpdateDragHilite function redraws the portion of the drag highlightwhich intersects the given updateRgn. This function is used if theapplication draws into the highlighted portion of the window during adrag. For example, dragging over a folder icon in the Finder causes theFinder to redraw the folder icon in its darkened (selected) color. TheFinder calls UpdateDragHilite to redraw any portion of the draghighlight that may have intersected with the folder icon.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0           No error                                               paramErr   -50         Parameter error                                        memFullErr -108        Not enough memory                                      badDragRefErr                                                                            -1851       Unknown drag reference                                 dragHiliteErr                                                                            -1870       Highlight is invalid                                   ______________________________________                                    

Drag Manager Utilities

The WaitMouseMoved function can be used to determine after a mouseDownevent if a drag should be started, the ZoomRects and ZoomRegionfunctions to provide "zooming" animation to provide destination or abortfeedback. TEGetHiliteRgn is used to obtain the highlight region from aselection in a TextEdit record.

WaitMouseMoved

When the application receives a mouseDown event on a draggable object,call WaitMouseMoved to determine if dragging the object should begin.

pascal Boolean WaitMouseMoved (Point initialMouse);

initialMouse--The point where a mouseDown event occurred. TheinitialMouse location is given in global screen coordinates.

The WaitMouseMoved function waits for either the mouse to move from thegiven initialMouse location or for the mouse button to be released. Ifthe mouse moves away from the initialMouse location before the mousebutton is released, WaitMouseMoved returns true. If the mouse button isreleased before the mouse moved from the initialMouse location,WaitMouseMoved returns false.

ZoomRects

The ZoomRects function is used to animate a rectangle into a secondrectangle. This routine is used to animate drag operations or abortfeedback, and a flowchart shows the operation of ZoomRects() in moredetail below.

    ______________________________________                                        pascal OSErr ZoomRects                                                                         (const Rect *fromRect,                                                        const Rect *toRect,                                                           short zoomSteps,                                                              short zoomAcceleration,                                                       ZoomProc callback,                                                            void *callbackData);                                         ______________________________________                                    

fromRect--Specifies the starting rectangle to animate from, in globalcoordinates.

toRect--Specifies the ending rectangle to animate to, in globalcoordinates.

zoomSteps--Specifies the number of animation steps that are shownbetween the source and destination rectangles. The minimum number ofzoomSteps is 4. If less than 4 are specified, 4 will be used. Themaximum number of zoomSteps is 25. If more than 25 are specified, 25will be used.

zoomAcceleration--Specifies how the intermediate animation steps will becalculated. This function can accept the constants kZoomNoAccelerate,kZoomAccelerate, or kZoomDecelerate. Using kZoomNoAccelerate makes thedistance between steps from the source to the destination equal. UsingkZoomAccelerate makes each step from the source to the destinationincreasingly larger, making the animation appear to speed up as itapproaches the destination. Using kZoomDecelerate makes each step fromthe source to the destination smaller, making the animation appear toslow down as it approaches the destination.

callback--A routine that will be called if there is extra processor timeduring the zoom. If idle time is not needed during the animation, NILmay be passed by the handler.

callbackData--A reference constant passed to the callback routine.

The ZoomRects function animates a movement between two rectangles on thescreen. It does this by drawing gray dithered rectangles incrementallytoward the destination rectangle. This was illustrated with reference toFIGS. 20a-20c.

ZoomRects draws on the entire screen, outside of the current port. Itdoes not change any pixels on the screen after it has completed itsanimation. It also preserves the current port and the port's settings.

Each step of animation will occur no faster than once per Tick (onesixtieth of a second). If ZoomRects completes an animation step in lessthan one Tick, ZoomRects calls the callback routine that can use theleft over idle time.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0              No error                                            paramErr   -50            Parameter error                                     ______________________________________                                    

ZoomRegion

The ZoomRegion function is used to animate a region's outline from onescreen location to another. This routine provides the same visualfeedback that the Finder uses to "zoom" icons when performing a Clean Upoperation.

    ______________________________________                                        pascal OSErr ZoomRegion                                                                         (RgnHandle region,                                                            Point zoomDistance,                                                           short zoomSteps,                                                              short zoomAcceleration,                                                       ZoomProc callback,                                                            void *callbackData);                                        ______________________________________                                    

region--A region to animate.

zoomDistance--The horizontal and vertical distance from the startingpoint that the region will animate to.

zoomSteps--Specifies the number of animation steps that are shownbetween the source and destination regions. The minimum number ofzoomSteps is 4. If less than 4 are specified, 4 will be used. Themaximum number of zoomSteps is 25. If more than 25 are specified, 25will be used.

zoomAcceleration--Specifies how the intermediate animation steps will becalculated. Can accept the constants kZoomNoAccelerate, kZoomAccelerate,or kZoomDecelerate. Using kZoomNoAccelerate makes the distance betweensteps from the source to the destination equal. Using kZoomAcceleratemakes each step from the source to the destination increasingly larger,making the animation appear to speed up as it approaches thedestination. Using kZoomDecelerate makes each step from the source tothe destination smaller, making the animation appear to slow down as itapproaches the destination.

callback--A routine that will be called if there is extra processor timeduring the zoom. If idle time is not needed during the animation, NILmay be passed. See the ZoomProc definition below for more details.

callbackData--A reference constant passed to the callback routine.

The Zoom Region function animates a region from one location to anotheron the screen. It does this by drawing gray dithered regionsincrementally toward the destination region.

ZoomRegion draws on the entire screen, outside of the current port. Itdoes not change any pixels on the screen after it has completed itsanimation. It also preserves the current port and the port's settings.

Each step of animation will occur no faster than once per Tick (onesixtieth of a second). If ZoomRegion completes an animation step in lessthan one Tick, ZoomRegion calls the callback routine that can use theleft over idle time.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0              No error                                            paramErr   -50            Parameter error                                     ______________________________________                                    

TEGetHiliteRgn

The TEGetHiliteRgn function is used to get the highlight region from thecurrent selection in a TextEdit record.

    ______________________________________                                        pascal OSErr TEGetHiliteRgn                                                                      (RgnHandle region,                                                            TEHandle hTE);                                             ______________________________________                                    

region--The TEGetHiliteRgn function computes the QuickDraw region of thecurrent selection in the given TextEdit handle. This region is placedinto the region parameter that has already been allocated. This regionis in the window's local screen coordinates.

hTE--A TextEdit handle.

The TEGetHiliteRgn function returns in the region parameter the regionof the current selection in the given TextEdit handle.

TEGetHiliteRgn does not allocate a new region. A new region must becreated with NewRgn before calling TEGetHiliteRgn. Also, the previouscontents of the given are completely replaced by the TextEdit selectionregion.

If the given TextEdit handle does not currently have a selection,TEGetHiliteRgn returns an empty region.

    ______________________________________                                        Result Codes:                                                                 ______________________________________                                        noErr      0             No error                                             paramErr   -50           Parameter error                                      memFullErr -108          Not enough memory                                    ______________________________________                                    

Application-Defined Routines

This section describes the application-defined routines whose addressesare passed to the Drag Manager. Routines are typically, but notnecessarily, defined that the Drag Manager calls during a drag can bedefined to implement dragging behavior both into and out of theapplication's windows.

Drag Handler Routines

Most of the application's dragging functionality is implemented throughthe use of drag handlers. The Drag Manager calls an application's draghandlers when a drag originates from one of the application's windows (aSendDrag handler), while the user drags a collection of items throughone of the application's windows (a tracking handler), and when the userdrops the items into one of the application's windows (a receivehandler).

DragTrackingHandler

A drag tracking handler has the following syntax:

    ______________________________________                                        pascal OSErr DragTrackingHandler                                                                (short message,                                                               Point pinnedMouse,                                                            WindowPtr theWindow,                                                          unsigned long handlerRefCon,                                                  DragReference theDragRef);                                  ______________________________________                                    

message--A tracking message from the Drag Manager.

pinnedMouse--The pinned mouse location, in global coordinates.

theWindow--A pointer to the window that the mouse is over.

handlerRefCon--A reference constant that was provided toInstallTrackingHandler when this handler was installed.

theDragRef--The drag reference of the drag.

The Drag Manager calls the application program's DragTrackingHandlerroutine during a drag when the user moves the mouse over one of theapplication's windows. The application program's DragTrackingHandler candetermine what is being dragged by calling the drag item informationfunctions, such as CountDragItems, CountDragItemFlavors, GetFlavorTypeand GetFlavorFlags.

The message parameter can be used to determine what action theapplication program's DragTrackingHandler should take. The messageparameter may be one of the following values:

Message Descriptions

kDragEnterHandlerMessage--A call will be received with this message whenthe focus of a drag enters a window that is handled by the applicationprogram's DragTrackingHandler. If the user moves the drag directly toanother window that is handled by the same DragTrackingHandler, a secondKDragEnterHandlerMessage is not received. The application program'sDragTrackingHandler only receives this message when the drag enters thedomain of the procedure after leaving another.

kDragEnterWindowMessage--A call will be received with this message whena drag enters any window that is handled by the application program'sDragTrackingHandler. This message is sent to the application program'sDragTrackingHandler for each window that the drag may enter. Thismessage will always be received within a pair ofkDragEnterHandlerMessage and kDragLeaveHandlerMessage calls.

kDraglnWindowMessage--Calls will be received with this message as theuser is dragging within a window handled by the application program'sDragTrackingHandler. This message can be used to track the draggingprocess through the window. This message will always be received withina pair of kDragEnterWindowMessage and kDragLeaveWindowMessage calls. Themajority of the window highlighting and object tracking will typicallybe drawn when this message is received from the Drag Manager.

kDragLeaveWindowMessage--A call will be received with this message whena drag leaves any window that is handled by the application program'sDragTrackingHandler. This message is received after receiving acorresponding kDragEnterWindowMessage. This message will always bereceived within a pair of kDragEnterHandlerMessage andkDragLeaveHandlerMessage calls.

kDragLeaveHandlerMessage--A call will be received with this message whenthe focus of a drag enters a window that is not handled by theapplication program's DragTrackingHandler. This message is guaranteed tobe received after receiving a corresponding kDragEnterHandlerMessage.

When the Drag Manager calls the application program'sDragTrackingHandler, the port will be set to the window that the mouseis over.

ReceiveDropHandler

A receive drop handler has the following syntax:

    ______________________________________                                        pascal OSErr ReceiveDropHandler                                                                (WindowPtr theWindow,                                                         unsigned long handlerRefCon,                                                  DragReference theDragRef);                                   ______________________________________                                    

theWindow--A pointer to the window that the drop occurred in.

handlerRefCon--A reference constant that was provided toInstallReceiveHandler when this handler was installed.

theDragRef--The drag reference of the drag.

When the user releases a drag in a window, the Drag Manager calls anyReceiveDropHandler functions that have been installed on that window. Auser can get the drop location and what data is being dragged todetermine if the window will accept the drop by using the draginformation functions provided by the Drag Manager.

After the application program's ReceiveDropHandler decides that it canaccept the drop, use the GetFlavorData function to get the needed datafrom the sender of the drag.

When the Drag Manager calls the application program'sReceiveDropHandler, the port will be set to the window that the mouse isover.

DragConstrainHandler

A drag constrain mouse handler has the following syntax:

    ______________________________________                                        pascal OSErr DragConstrainHandler                                                               (Point mouse,                                                                 Point *constrainedMouse,                                                      unsigned long handlerRefCon,                                                  DragReference theDragRef);                                  ______________________________________                                    

mouse--The current mouse location in global screen coordinates.

constrainedMouse The constrainedMouse parameter, on entry, contains theconstrained mouse coordinates produced by the last DragConstrainHandlercalled or it contains the mouse coordinates if it is the firstDragConstrainHandler to be called. The constrainedMouse parameter, onexit, should be set to the newly constrained mouse location by theapplication program's DragConstrainHandler. The constrainedMousecoordinates are specified in global screen coordinates.

handlerRefCon--A reference constant that was provided toInstallConstrainHandler when this handler was installed.

theDragRef--The drag reference of the drag.

When the mouse moves over a window, any DragConstrainHandlers that areinstalled on that window are called sequentially to give each handlerthe opportunity to constrain the mouse movement.

The application program's DragConstrainHandler is called after the DragManager has sampled the mouse location, but before it uses the mouselocation to move the "dotted outline" drag region on the screen. Theapplication program's DragConstrainHandler can modify the mouse locationin any way, such as horizontal, diagonal or grid constraint. The DragManager does not, however, use the constrained mouse location todetermine which window to send handler messages to.

If there are more than one constrain mouse handlers installed on asingle window, the handlers will be called sequentially, where the firsthandler will receive the real mouse location in the constrainedMouseparameter, and subsequent handlers will receive the result of theprevious handler in the constrainedMouse parameter.

When the Drag Manager calls the application program'sDragConstrainHandler, the port will be set to the window that the mouseis over.

DragCallback Procedures

There are several Drag Manager functions that can be overridden bysetting any of several drag callback procedures for any given drag. Theavailable drag callback procedures override the standard flavor datasending, mouse and keyboard sampling and "dotted outline" drag regiondrawing functions.

DragSendDataProc

A drag send data procedure has the following syntax:

    ______________________________________                                        pascal OSErr DragSendDataProc                                                                 (FlavorType theType,                                                          const AEDesc *acceptorDescriptor,                                             unsigned long theRefCon,                                                      ItemReference theItemRef,                                                     DragReference theDragRef);                                    ______________________________________                                    

theType--A flavor type being requested by a drop receiver.

acceptorDescriptor--An optional AppleEvent description of the droplocation that the data will be sent to.

theRefCon--A reference constant that was provided when SetDragSendProcwas called to install this procedure.

theItemRef--The item reference of the item that the flavor data is beingrequested from.

theDragRef--The drag reference of the drag.

The Drag Manager calls the application program's DragSendProc when dragitem flavor data is requested by a drop receiver if the drag item flavordata is not already cached by the Drag Manager. TheSetDragItemFlavorData function is used to give the Drag Manager therequested data.

The Drag Manager caches all drag item flavor data that was given in thedata pointer when the flavor was added using the AddDragItemFlavorfunction. If the data pointer is NIL when the flavor is added, the DragManager will call the DragSendProc to get the data only if a receiverrequests the data using the GetFlavorData function.

A second scenario where the DragSendProc is called is when a dropreceiver requests a flavor that is translated by the Translation Managerand the source data (which would be a different type than actuallyrequested by the receiver) is not already cached by the Drag Manager.

A DragSendDataProc does not need to be provided if NIL is not everpassed as the data pointer when calling AddDragItemFlavor.

DragInputProc

A drag input procedure has the following syntax:

    ______________________________________                                        pascal OSErr DragInputProc                                                                      (Point *mouse,                                                                short *modifiers,                                                             unsigned long theRefCon);                                   ______________________________________                                    

mouse--On entry, the mouse parameter contains the physical location ofthe mouse. On exit, the application program's DragInputProc returns thedesired current mouse location in the mouse parameter. The mouselocation is specified in global screen coordinates.

modifiers--On entry, the modifiers parameter contains the physical stateof the keyboard modifiers and mouse button. On exit, the applicationprogram's DragInputProc returns the desired state of the keyboardmodifiers and mouse button. The modifiers parameter is specified usingthe same format and constants as the Event Manager's EventRecordmodifiers field.

theRefCon--A reference constant that was provided when SetDragInputProcwas called to install this procedure.

Each time the Drag Manager samples the mouse and keyboard, it calls theDragInputProc (if one has been set by calling SetDragInputProc) toprovide way to modify or completely change the mouse and keyboard inputto the Drag Manager.

When the DragInputProc is called, the mouse and modifiers parameterscontain the actual values from the physical input devices. Theapplication program's DragInputProc may modify these values in any way.The application program's DragInputProc may simply inhibit the controlkey modifier bit to become set or it may completely replace the mousecoordinates with those generated some other way to drive the dragitself.

DragDrawingProc

A drag drawing procedure has the following syntax:

    ______________________________________                                        pascal OSErr DragDrawingProc                                                                    (short message,                                                               Point pinnedMouse,                                                            unsigned long theRefCon,                                                      DragReference theDragRef);                                  ______________________________________                                    

message--A drag region drawing message from the Drag Manager.

pinnedMouse--The pinned mouse location, in global coordinates.

theRefCon--A reference constant that was provided whenSetDragDrawingProc was called to install this procedure.

theDragRef--The drag reference of the drag.

If the application set a custom drawing procedure for a drag using theSetDragDrawingProc function, the Drag Manager calls the applicationprogram's DragDrawingProc to perform all drag region drawing operations.

The message parameter is used to determine what action the applicationprogram's DragDrawingProc should take. The message parameter may be oneof the following values:

Message Descriptions

kDragPrimeDrawingMessage--A call will be received with this message whena drag is being started and it is time to initialize the applicationprogram's drawing procedure. Nothing should be drawn to the screen whenthis message is received.

kDragDrawMessage--A call will be received with this message when thedrag feedback should be drawn at the pinnedMouse location. The DragManager port is set such that a user can draw to the entire screen.Successive kDragDrawMessage calls will be received to move the dragfeedback on the screen.

kDragHideMessage--Calls will be received with this message when the dragfeedback should be erased from the pinnedMouse location. The DragManager port is set such that a user can draw to the entire screen.

kDragDrawldleMessage--A call will be received with this message when thedrag region has not moved on the screen. This message can be used if anytype of animation is being drawn to update the application program'sdrag region. The Drag Manager port is set such that a user can draw tothe entire screen.

kDragEndDrawingMessage--A call will be received with this message whenthe drag has completed and it is time to deallocate any allocations madeduring in the application program's DragDrawingProc. After this messageis received, any additional messages will not be received.

Functional Operation

Another inventive feature of the preferred embodiment is the definitionof a new type of process switching mechanism which accelerates theresponse time of drag-and-drop operations, and thus makes suchinterapplication dragging a truly useful and feasible alternative. Prioran systems for performing task switching typically are similar to thatillustrated in FIGS. 26 and 27. For example, the prior an assumes asingle-master slave relationship wherein a master program retainscontrol, and all slave programs must return control to the masterprogram upon completing their tasks. This is briefly illustrated withreference to the timing diagram of FIG. 26. For example, a master mayretain control of the computer's operation, however, at time t₁, at suchtime it is determined that a slave process should be transferred controlto perform some operations, such as highlighting a window, selectingtext or other type of operation, a context switch takes place whereintransfer is controlled to a slave S₁. The slave S₁ performs someprocessing for some duration of time and then, at some point, returnscontrol back to the master at time t₂. Again, the master retains controlfor a certain interval and may transfer control to another slave, suchas S₂ illustrated at time t₃, which slave returns control back at timet₄. This type of mechanism may also be illustrated by FIG. 27 whichshows the master and slave illustrated as a series of states whereineach slave process is represented as a state which always returns backto the master state. Therefore, control is to be allocated by themaster, and control always returns to the master at the completion ofprocessing by any slave.

The preferred embodiment assumes a more distributed context switchingapparatus wherein each process in the computer system is assumed toprovide all control for the display and other necessary processingduring the time in which it is transferred control. In this manner, nocontrol needs to be returned to master, and each process which is activein the system transfers complete control of the display and otheractions taking place. This model is known in the preferred embodiment asthe "hot potato model" or "peer-to-peer-to-peer." This isdistinguishable from master/slave or the server/client control in theprior art, as was illustrated with reference to FIGS. 26 and 27. Theflow of control can be briefly illustrated by reference to FIGS. 28 and29. For example, with reference to FIG. 28, proceeding at time t₁wherein a context switch takes place, a first interactor I₁ may havecontrol. Then, upon detection that a second interactor needs to obtaincontrol, I₁ performs all necessary functions for housekeeping prior toleaving that process, and control is switched at time t₁ through use ofa context switch to interactor I₂. Similarly, I₂ retains control for acertain duration of time, and then, at time t₂, I₂ begins a switchcontext again to a third process I₃. This type of context switching cantake place any and all of the processes in the system with no process orinteractor being required to retain control, as in the master/slave orserver/client relationships.

Yet another view of this model is illustrated with reference to FIG. 29.For example, interactor I₁ may have control and transfer that control toI₂, as illustrated by transition line 2900 in FIG. 29. Further, I₂ mayretain control for a period of time and transfer control to a thirdinteractor I₃. This process continues, as discussed above, with nointeractor requiring that another interactor returns control back to it,as was required in the master/slave relationship. This technique hasperformance advantages in that only a single-context switch to switchcontrol from one interactor to another is required. This isdistinguishable from the master/slave relationship wherein if controlwants to be transferred to a second slave (e.g., S₂ in FIG. 26), thencontrol has to be retained from a first slave (e.g., S₁), and thencontrol must be transferred to S₂. This is illustrated at times t₂ andt₃ in FIG. 26. In contrast, as is illustrated in FIG. 28, if oneinteractor desires control, such as interactor I₂ at time t₁, then onlya single-context switch between interactors I₁ and I₂ need take place att₁. Thus, significant performance advantages are realized by onlyperforming a single-context switch per transfer of control from oneinteractor, such as I₁, to a second interactor, such as I₂. Thisparticular type of switching model is useful when transfers of contextbetween windows in the user's computer system need take place. So, forexample, to transfer control from a first interactor, such as I₁, to asecond interactor, such as I₂, when the tracking of a mouse goes from awindow handled by interactor I₁ to a second window handled by interactorI₂, then a message is merely sent from the Drag Manager to I₂ causingthe second process to assume control.

For example, the sending application, such as I₁, may track the drag, dowhatever highlighting is appropriate, until the mouse moves into awindow belonging to another application program, such as interactor I₂.The sending application program I₁ sends the destination applicationprogram under the mouse event effectively transferring control, and thereceiver, such as I₂, is now in complete control until the mouse movesover a window handled by a different application program. Applicationsthus pass control around like a hot potato, each is in total controluntil it decides to pass control to another application program. Thus,each interactor is required to only implement the slave functionalityand the functionality to transfer control to a different applicationprogram.

Transfer of control is implemented in the preferred embodiment using aProcess Manager switch mechanism. The switch mechanism allows the DragManager to efficiently change which application context is current. TheDrag Manager uses this mechanism to prepare handlers to receivemessages. This allows it to quickly change which application has controlof the drag by immediately calling the new application handlers directlyin their own context. This is a significant improvement over EventManager based messages, which correctly set contexts but are slowerbecause of overhead. In the following discussion, in the preferredembodiment, three cases are handled: a selection in a foreground(currently active) application's window and possible drag; a selectionin a background window and possible drag; and a drop in a backgroundwindow. These cases are handled through the use of a process TrackDragdescribed with reference to FIGS. 30 and 31 and related process at FIGS.32-34.

For example, process 3100 of FIGS. 30 and 31 illustrates the transfer ofcontrol which occurs in a process known as TrackDrag, which may occurupon detection of a drag (e.g., the selection of an item and movement ofthree pixels or more while selected) and the appropriate calls to thehandlers. This process, which starts at step 3101, determines, basedupon the position of the cursor on the user interface display, theposition of the pointing device or mouse at step 3102 and updates theposition of the cursor on the display. It can be determined at step 3103which application program controls the window under the mouse bydetermining the cursor position in global coordinates and determiningwhich window is under the cursor at step 3103. Each window hasassociated with it a routine which controls the window (e.g., the mainapplication program). Then, at step 3104, a layer switch to theapplication occurs for implementation purposes to allow the Drag Managerto determine which window controlled by the application has beenselected. Thus, if an application has several different registered setsof handlers for different windows (e.g., 2211 and 2212 of FIG. 22 forwindow "graphics" or 2221 for window "documents"), then the properhandlers can be accessed, and a switch of handlers and/or applicationsmay be performed. It can then be determined at step 3105 which window ispointed to by the cursor that is handled by the application. That is, asingle application program may have several windows displayed, one ofwhich only is handled by the application, each of which has a set ofhandlers associated registered with it in the handler list (see, e.g.,FIG. 22). Then, it is determined at step 3107 whether the handler isdifferent, via its callback and process ID, from the current handlersloaded at step 3107. If so, then a switch of handlers is performed atstep 3108. As was discussed with reference to the messages above, therespective handlers are transmitted messages indicating whether thehandlers are being left or entered. Thus, the old handler for either theold window or old application program receives a kLeaveHandler message,and the new handler receives a kEnterHandler message. If the handler isnot different, as determined at step 3107, then process 3100 continuesat step 3111a in FIG. 31.

Once handlers have been switched at step 3108, it is determined whetherthe handler belongs to a different application program at step 3109. Ifso, then an application context switch is performed at step 3110. Thisis a limited switch, of only the context of the application and that theactivation of the application itself. This allows the handler access toany global variables and routines in the application program (in theMacintosh® brand operating system known as a switch to allow the handlerto have access to the A5 global variables of the application program).This allows the handler to determine, if a background selection wasmade, the content and flavors of a drag item or, in the case of abackground drop, allows rewrapping and other reformatting of informationin the background window without activation of the application program.Thus, the handler can have access to the facilities provided by theapplication without activation of the application. It is then determinedwhether the new application (e.g., the handler of the context) is validand active at step 3111. Subsequently, at step 3111a, InWindow messagesare sent to the handler(s) to indicate that a window that the handler(s)control should take action. This occurs if a different handler was notdetected at step 3107 or if the handlers did not belong to a differentapplication program at step 3109. If any errors occur, as determined atstep 3112, or the new application was not valid or not active, asdetermined at step 3111, then control is retained at step 3115 by thecurrent application. This is not fatal, as the application window underthe cursor simply will not be able to receive the dragged data, nohandlers are called, and the window is not highlighted. If, however, theuser causes a mouse-up event (deactivation of the selection device toindicate a drop), as detected at step 3117, then process 3100 aborts atstep 3118, and abort feedback may be provided to the user. As will bediscussed, and was referenced above, the process ZoomRects() may be usedfor this purpose to animate that the drag was, in fact, not successful.Thus, at step 3119, the TrackDrag process is returned from at step 3119,as is illustrated in FIG. 31. If a mouse-up event is not detected atstep 3117, then TrackDrag 3100 returns to the top of the loop at step3102.

If, however, an error was not detected at step 3112 from the activationof the new application program context at step 3111, then it isdetermined whether, at step 3113, a mouse-up event has occurred. Thiswill indicate that the user wishes to "drop" the dragged data to thewindow over which the cursor now resides. In that case, process 3100proceeds to call DragReceive process 3400 for the application program.This is illustrated in more detail with reference to FIG. 34 below.Then, at step 3114, it is determined whether the call to the DragReceiveprocess for the application program resulted in the receipt of any data.If not, then step 3114 branches to step 3118 which provides abortfeedback to the user (such as through the use of ZoomRects or other userinterface function), and process 3100 returns at step 3119. If, however,the DragReceive process for the application did receive the data, asdetermined at step 3114, then the process normally returns at step 3119with all the necessary drop completion feedback being provided by theuser by DragReceive process 3400 for the application program.

FIG. 32 illustrates a process 3200 which is performed within the normalevent loop of a front application window (the active process) which hasalready been switched in and needs to perform a StartDrag process inorder to create drag items or flavors which the sending process cantransmit. Then, at step 3202, the application detects the position ofthe cursor and a movement of three pixels after a mouse-down event and aselection. If there is no movement of three pixels after a selection andmouse-down event, then the normal event loop continues at WaitNextEventat step 3206. The application program uses the process NewDrag providedby the application program at step 3203 if a drag was detected to startthe drag. The application program's NewDrag process adds drag items withtransmittable flavors at step 3203 and does not need to be switched inbecause it is already active and loaded. The application program thencalls the TrackDrag process at step 3204. Of course, the drag items withtransmittable flavors are only created if the application program isdrag aware, and if it not, then it does not call TrackDrag. TheTranslation Manager is invoked at step 3205 by TrackDrag process 3100 toadd flavors to the drag item(s). Based upon flavors provided by theapplication program, the Translation Manager determines other flavors itcan provide the data in. That is, if the type `styl` was a drag itemflavor provided by the application program and the Translation Managercan provide an `.rtf` flavor, then the Translation Manager will add theflavor `.rtf` to the drag item flavors list in the drag data structure.Then, upon completion, the Drag Manager begins to track the drag asdescribed TrackDrag process 3100 described above.

A process for a background application is illustrated with reference toFIGS. 33a and 33b. This is used in the event that a drag is started froma window which was inactive or in the background. Process 3300 of FIGS.33a and 33b starts at step 3301 which recognizes the mouse-down event ina background application window. This may be determined by checking theapplication program associated with the window where the selection tookplace. If that application is not active, then it is considered to be abackground selection. Then, it is determined at step 3302 whether abackground mouse-down handler has been installed for the backgroundapplication. If not, then the process proceeds to step 3315 on FIG. 33b.If there is a background mouse-down handler installed for the backgroundapplication program, which is the most likely case in the case of a dragaware background application program, then process 3300 proceeds to step3303. Step 3303 performs a context switch to the background applicationprogram (the background mouse-down event handler is invoked for theapplication program, and the A5 global variables are made available),and at step 3304, the background mouse-down handler is sent themouse-down event. The handler receives the event at step 3308 anddetermines whether the cursor has moved three pixels or more after amouse-down event and selection at step 3309. If not, the handler returnsat step 3310 with the flag EventNotHandled. Otherwise, the handler thenproceeds, in a similar manner, to process 3200 wherein, at step 3311,NewDrag is called to create drag item(s) and flavors, TrackDrag iscalled at step 3312, and TrackDrag calls the Translation Manager at step3313, and the handler returns at step 3314 with the flag EventHandled.

FIG. 33b, starting at step 3312, illustrates the case where a TrackDragprocess was not started or a handler was not installed for thebackground application. In either event, as shown in FIG. 33b, it isassumed that the mouse-down event will cause a control switch to thebackground application program wherein a context switch is performed tothe front application at step 3315 to recognize that the drag processaborted, and at step 3316, it is assumed that the background applicationis not drag aware. Then, a switch is performed to the backgroundapplication program to make it active at step 3317 (control istransferred entirely to the background application), and a simplemouse-down event is sent to the background application program at step3318. The background application program detects the event in its normalevent loop and services the mouse-down event in the normal manner as theactive application program.

Process 3400 of FIG. 34 shows a sequence of steps which are performed bythe Drag Manager when a mouse-up event has been detected in the dragtracking process 3100 of FIGS. 30 and 31. For example, at step 3401, amouse-up event has already been detected. Then, at step 3403, theDragReceive process of the destination application is invoked. Thisallows the destination application program's receive handler to beinvoked which communicates messages to the Drag Manager to provide thevarious flavors of data requested by the receiving process. At step3405, the DragReceive process of the background application programrequests the flavors of data from the Drag Manager and thus the sendinghandler. If the sending handler can provide the flavor, as detected atstep 3407, then it is determined whether that flavor needs translationat step 3409. If so, then the Translation Manager is invoked at step3411 to translate the data, and data is returned to the DragReceiveprocess at step 3413. If the flavor does not need translation, asdetected at step 3409, then data is returned normally and untranslatedto the DragReceive process of the destination application program atstep 3413. If there are any other flavors of interest, as requested bythe DragReceive process at step 3415, then process 3400 continues atstep 3405. If, however, there are no other flavors of interest requestedby the DragReceive process of the application program, then process 3400is complete at step 3416 and returns.

The foregoing switching mechanism, especially that described withregards to the tracking process illustrated in process 3100, assumesthat the Drag Manager is in control and provides all message passingbetween the various handlers in the system. In the current preferredembodiment, control is typically returned to the Drag Manager in itsdrag tracking process 3100 in order to transfer control to a second setof handlers and/or switch context between application programs. However,it is anticipated that, in an alternative embodiment, the methodologyset forth in FIGS. 30-34 is implemented in individual applicationprograms in order to provide for interapplication dragging and transferof control to and from other application programs. Thus, in this manner,only a single message from the process relinquishing control to the newprocess need be made, and the process relinquishing control will performan orderly shutdown and transfer control. Message passing is kept to aminimum, and performance can be maximized.

Thus, it can be appreciated by the foregoing discussion that processswitching between application programs is simplified, and performance isenhanced by the use of peer-to-peer-to-peer context switching modeldescribed above. Other advantages, features, and performanceenhancements can be appreciated by one skilled in the art.

EXAMPLE USER INTERFACE ROUTINES

Certain user interface actions for providing feedback to a user duringdrag-and-drop operations can be illustrated with reference to theprocess flow diagrams of FIGS. 35-37. For example, FIG. 35 illustratesthe technique of starting a Drag Hilite Feedback which is used forrepresenting arbitrary shapes during drag feedback. This same techniqueis used for representing arbitrary shapes of items during tracking(e.g., windows, subwindows, fields, spreadsheet cells, etc.).

For example, as is illustrated in FIG. 35, the Start Drag HiliteFeedback procedure starts at step 3501. Then, a region shape is passedby the application's handler to the StartDragHilite function, such asthe icon and title or other representation of the item and the positionof the item. The passed region is then copied at step 3502. The regionis then inset or outset by a certain fixed thickness at step 3503 (e.g.,a single pixel outset for selection feedback or two or three pixel insetfor tracking feedback). Then, an exclusive OR is performed on theoriginal shape and the outset or inset region at step 3504, and theresult is drawn on the screen at step 3505. The resulting region eitherinsets or outsets the frame of a possible drag destination or an itemduring a drag. It also provides feedback that an arbitrarily shaped areaof the screen can successfully receive a drop. This same technique canalso be used for tracking the drag of the cursor across the userinterface screen and provides arbitrary shapes for feedback to the userduring drag operations.

Other prior art systems sometimes use arbitrary shapes, however, manyuse a fixed shape for performing drags between applications, and someeven use them during drags within their own file system. Thus, thismethod provides distinct advantages and improved user feedback over theprior art.

FIG. 36a-36c illustrate a simple procedure used for maintaininghighlighting during autoscrolling. For example, at step 3601, the StartDrag Hilite Scrolling procedure is started. Then, prior to scrolling thedata on the display at step 3602, the highlighted portions which will bescrolled out of the window are erased. A more detailed view of this stepis illustrated with reference to FIG. 36b. For example, during anautoscrolling operation, depending on the direction which theautoscrolling is taking place, the highlight region is copied at step3610, illustrated in FIG. 36b. Then, the copy which was made is offsetby a scroll amount (e.g., 10 pixels vertically and 3 pixelshorizontally) at step 3611. Then, a difference region from thedifference of the two regions is created at step 3612. The differenceregion is offset back by a certain scroll amount at step 3613. Then, atstep 3614, the difference region is erased from the display during thescroll.

At step 3603, as is illustrated in FIG. 36a, the application thenscrolls the contents of the pane or window by the defined scroll amount.At step 3604, the portions of the highlight after the scrolling arerestored at step 3604 are restored. This is shown in more detail withreference to FIG. 36c. As is illustrated in 36c, step 3621 is performedto find the difference region which was used earlier to perform thescroll. Then, at step 3622, an exclusive OR is made with the differenceregion and the ideal highlight region. Finally, at step 3623, the finalhighlighting on the display during the scroll is restored, and thewindow or frame is highlighted back to the state it was in prior to thescroll.

Other user interface feedback is provided, as is illustrated in FIG. 37.This is the abort or completion feedback process entitled ZoomRects. Forexample, this process starts at step 3701 wherein the starting andending drag objects and locations in global coordinates are passed tothe process by the invoking handler. Then, an outline region of thedragged object(s) is displayed at step 3702. A frame of the region isthen displayed at step 3703. It is determined at step 3704 whether fourframes (the default, or n if specified in the call by the application'shandler) are present on the screen, and, if so, then the oldest frame iserased at step 3705. If less than 12 frames have been drawn (the minimumto animate feedback), as determined at step 3706, then another frame isdrawn at step 3703 back and process 3700 repeats steps 3704-3706. Uponreaching the destination on the display, if any frames are left on thedisplay at step 3707, then process 3700 proceeds back to step 3705 toerase the oldest frame. Once all the frames have been erased from thedisplay at step 3708, the process is complete, and rectangles have beendrawn from the destination to the source location for abort feedback or,alternatively, in the case of destination feedback, from the source tothe destination location on the display. In either event, an animatedeffect is provided to the user on the display similar to that providedand described with reference to FIGS. 20a-20d.

Other user interface actions performed on the display (e.g., navigationfeedback, the profess bar, etc.) are performed using other techniqueswell-known to those skilled in the art.

Clipping

Interapplication dragging is one major feature provided by the preferredembodiment. This includes dragging between two different applicationprograms, two application windows, and windows controlled by the filemanager or Finder system service of the Macintosh® brand operatingsystem. The Finder is also treated as another application program fromthe perspective of the operating system, it also provides a mechanismfor receiving dragged data. In the case of a simple drag and drop to awindow in the file system, such as the desktop or a folder(subdirectory), a clipping is created which appears and can bemanipulated, as described above. Because this is a special and importantinstance of interapplication dragging, the detailed steps for generatinga clipping will be discussed with reference to FIGS. 38a-38d.

In the preferred embodiment, the Drag Manager scans through each of theitems in the drag item list and determines whether any are of the typewhich can be retrieved and stored as a file. This is shown withreference to FIG. 38a. For instance, the clipping process starts at step3801 (the process entry point) and begins with the first drag item atstep 3802. It determines whether this item contains a flavor of type`hfs` at step 3803. This allows the receiver to determine whether it isa file object being moved, for example, in the file system. If it is afile system object (it has a flavor of type `hfs`), as detected at step3803, then, at step 3805, the file system object of type `hfs` isretrieved from the drag item. Then, the file object is moved, and noclipping has been created. If, however, there is no flavor type of`hfs,` as determined at step 3803, then all drag item flavors providedby the sender are stored into a clipping file at step 3804. This is topreserve the fidelity of the data for any flavor(s) requested by areceiver subsequently receiving the clipping. Step 3804 is shown in moredetail with reference to FIG. 38b. If there are more drag items, asdetermined at step 3806, then process 3800 proceeds to step to the nextdrag item at step 3807, and steps 3803-3806 are performed repetitivelyuntil there are no more drag items left in the drag item list. Then,process 3800 ends at step 3808.

A more detailed view of step 3804 is illustrated with reference to FIG.38b. 3804 starts at the process entry point 3811 and determines, at step3812, by examining the flavors, whether there is a flavor of type`cnam.` This is the name that the application recommends be given to theclipping. If so, then the clipping file is created at step 3813 basedupon the `cnam` flavor data. For example, an application program, suchas a word processing program, may specify that clippings are to entitled"Word Processing Clipping 1," "Word Processing Clipping 2," etc. Inanother embodiment, the word processing document may give the clippingwith the selected text "This is text" the file name "This is text" inthe file system. Any file names of the application's choosing may bespecified in the `cnam` flavor specified by the application program.

Otherwise, if there is no specified `cnam` flavor indicated by thesending application program, then a clipping file is created with somedefault name, such as "Untitled Clipping," at step 3814. Then, at step3815, it is determined whether there is a drag item flavor `prxy.` Thisflavor is used for specifying the default appearance of the icon for theapplication's clipping. For example, the application program may desireto provide a miniature representation of a view of the dipping, such asa condensed view of a graphics image, or a miniature image of text.Again, like the naming example, this is application-dependent. Then, ifthem is a type `prxy` flavor in the drag item, then the `prxy` flavordata is retrieved and used as the appearance of the icon for theclipping file at step 3816. Otherwise, a default icon for the clippingfile, such as that for text (e.g., 781 in FIG. 7d) or graphic data(e.g., 780 in FIG. 7d) is used at step 3817. Step 3817 is shown in moredetail with reference to FIG. 38d. In either event, all of the drag itemflavors from the drag item(s) are retrieved from the sendingapplication, if needed, and stored into the dipping file at step 3818,as is illustrated in FIG. 38b. This is to provide the highest fidelityfor any application program which may subsequently desire to drop theclipping into one of its windows. This is shown in more detail withreference to FIG. 38c. In any event, upon storage of all the dragitem(s) and flavors into the clipping file, the process ends at step3819.

A more detailed view of step 3818 of process 3804 in FIG. 38b isillustrated with reference to FIG. 38c. For example, the process startsat process entry point 3821 and begins with the first drag item flavorlisted in the drag item flavor list at step 3822. If the flavor issenderOnly, (as indicated by a flag stored with the flavor), asdetermined at step 3823, then the flavor is skipped, and it isdetermined at step 3826 whether there are more flavors. If the flavor isnot sender only, as detected at step 3823, then it is determined whetherthe flavor has been translated by the Translation Manager at step 3824indicated by the flag TMTranslated. If so, because the maximum fidelityof the clipping needs to be retained, then that flavor also is skippedfor the creation of the clipping file since the translation of data mayresult in some loss in fidelity. No flavors which have been translatedshould be stored in the clipping. If the flavor is neither senderOnlynor TMTranslated, then the flavor being checked is added to the clippingfile at step 3825 wherein the data is requested from the sender, if notprovided in the drag item(s). Then, it is determined whether there aremore flavors at step 3826, and, if so, then the next drag item flavor inthe drag item flavor list is retrieved. Steps 3823-3827 repeat until theprocess ends at step 3828.

FIG. 38d illustrates the subprocess which is used for determining theappropriate icon to associate with the clipping file, as referred to atstep 3817 in FIG. 38b. The process enters at step 3831 and begins byviewing the first drag item flavor at step 3832. Then, various flavorsare tested for at steps 3833-3842 to associate with the file the defaulticon requesting the first flavor recognized by the clipping process. Forexample, the process determines whether the flavor type is of type"TEXT" at step 3833, and if so, then the default text icon (e.g., 781 inFIG. 7d) is used to represent the clipping at step 3834. The processthen ends at step 3835. If the flavor is of type `PICT,` as determinedat step 3836, then the picture icon is used at step 3837 (e.g., 780 ofFIG. 7d), and the process ends at step 3838. If the flavor type is oftype `snd,` indicating a sound clipping, then the sound icon is used(e.g., 784 of FIG. 7d) at step 3840, and the process ends at step 3841.If there are any additional flavors in the flavor list and an icon hasnot yet been assigned, as detected at step 3842, then the next drag itemflavor is skipped to at step 3844 to determine another default icon maybe associated with the clipping. Otherwise, if there are no more flavorsto scan, as detected at step 3842, then the generic icon (e.g., 782 ofFIG. 7d) is used to represent the clipping file at step 3843, and theprocess ends at step 3841.

Verb Selection

One method already referred to, but which may be better understood by amore detailed discussion, is verb selection. This is discussed withreference to FIG. 39. This process may be performed by a drag receivehandler in a receiving process upon the detection of a mouse-up event(the release of a selection device). This is especially useful forsystem services (e.g., a printing service or a mailing service) but mayalso be performed by other receivers having specific functions. Forexample, the application program may invoke verb selection process 3900to perform various actions. The process starts at entry point 3901, and,at step 3902, the process scans through the flavors and compare each ofthe flavors with possible actions to be performed by the destination.Each of the flavors are listed in hierarchical order so that preferredflavors are listed first, with less preferred listed last. Also, thedestination will have a series of actions associated with it inhierarchical order and flavors associated with each action. For example,a printing process may have a primary verb "print" which prefers aflavor of `styl` to perform the printing. Alternatively, the process mayalso be able to perform a function such as "copy" in the file system andrequire a flavor of `hfs.` In either event, primary actions may becompared with flavors of the drag item(s) and arranged from most likelyverb, given the flavor(s), to least likely verb. The user may thenspecify whether the primary or secondary (or other action) should takeplace by selecting certain keys. For example, at step 3903, if the"control" key has been selected by the user, then this may cause thedialog window with the verbs to be displayed and manually selected bythe user at step 3907. For example, such a dialog window to allow a userto select verbs based upon flavors and actions may be displayed, asillustrated in FIG. 21 above. If so, then the selection made by the usercan be detected at step 3908, and the flavors for the selected verb canbe requested from the sending application program and the selectedaction can be performed at step 3909.

If, however, the "control" key was not selected, as detected at step3903, then it can be determined whether the "option" key has beenselected, as detected at step 3904. If not, then the most likely verb tobe performed is selected at step 3906 (e.g., a "move" verb in the caseof a movement of an icon within a single volume) and performed at step3909. If, however, the "option" key has been selected, as detected atstep 3904, then the second most likely verb is selected at step 3905. Inthe case of a single-volume file movement operation, this may cause a"copy" of the file represented by the icon to be performed. At any rate,the hierarchy is maintained and the first two most likely verbs may beaccessed by the user by selecting the "option" key. In any event, theselected action is performed by requesting flavor(s) from the receivingapplication, if needed, and the performance of the action at step 3909.The verb selection process is thus complete at step 3910.

SUMMARY

Thus, an improved interface and mechanism for manipulation of data in acomputer system has been described. Although the foregoing has beendescribed particularly with reference to FIGS. 1-39, it can beappreciated by one skilled in the art that many departures may be madewithout departing from the general spirit and scope of the presentinvention. Thus, the foregoing figures are merely to be viewed in anillustrative sense and in no way restrict the present invention.

What is claimed is:
 1. A method of associating routines for controllinguser actions in a computer controlled display system comprising thefollowing steps:a. registering each routine of a first plurality ofroutines for controlling said computer-controlled display system whensaid system is in a first context, each of said first plurality ofroutines operable when the system is in the first context andcontrolling different aspects of the functioning of said system; b.registering each routine of a second plurality of routines forcontrolling said computer-controlled display system when said system isin a second context, each of said second plurality of routines operablewhen the system is in the second context and controlling differentaspects of the functioning of said system; c. determining if saidcomputer controlled display system is in said first context thenantomatically sequentially executing each routine of said firstplurality of routines wherein at least one of said first plurality ofroutines performs an action in said system; and d. Otherwise,determining if said computer controlled display system is in said secondcontext then automatically sequentially executing each routine of saidsecond plurality of routines wherein at least one of said secondplurality of routines performs an action in said system.
 2. The methodof claim 1 wherein each of said first and said second plurality ofroutines controls the appearance of user interface icons on a display ofsaid system.
 3. The method of claim 1 wherein each of said first andsecond plurality of routines each respectively control differentportions of a first and second user interface display each respectivelyunder control of a first and second application program.
 4. A method ofassociating routines for controlling user actions in a computercontrolled display system comprising the following steps:a. registeringeach routine of a first plurality of routines for controlling saidcomputer-controlled display system when said system is in a firstcontext, each of said first plurality of routines operable when thesystem is in the first context and controlling different user interfaceobjects for a first application program in said system that operates inthe first context; b. registering each routine of a second plurality ofroutines for controlling said computer-controlled display system whensaid system is in a second context, each of said second plurality ofroutines operable when the system is in the second context andcontrolling different user interface objects for a second applicationprogram in said system that operates in the second context; c.determining if said computer controlled display system is in said firstcontext, and if so, then automatically sequentially executing eachroutine of said first plurality of routines wherein at least one of saidfirst plurality of routines updates a display in said system; and d.otherwise, determining if said computer controlled display system is insaid second context, and if so, then automatically sequentiallyexecuting each routine of said second plurality of routines wherein atleast one of said second plurality of routines updates said display insaid system.
 5. The method of claim 4 wherein said first and secondapplication programs specify said first and second plurality of routinesregistered.
 6. The method of claim 4 wherein said first plurality ofroutines comprises different routines for handling different userinterface windows controlled by said first application program.
 7. Themethod of claim 4 wherein said second plurality of routines comprisesdifferent routines for handling different user interface windowscontrolled by said second application program.
 8. The method as setforth in claim 4, further comprising the steps of: registering the firstplurality of routines with the first application; and registering thesecond plurality of routines with the second application.
 9. A displaysystem comprising:a computer processing system; a display coupled to thecomputer processing system; a first window located on the display whichoperates in a first context; a second window located on the displaywhich operates in a second context; a first plurality of registeredroutines, which when executed by the computer processing system, controlobjects in the first window on the display; a second plurality ofregistered routines, which when executed by the computer processingsystem, control objects in the second window on the display; saidcomputer processing system sequentially executing each of the firstplurality of routines to control objects in the first window when thecomputer processing system operates in the first context and saidcomputer processing system sequentially executing each of the secondplurality of routines to control objects in the second window when thecomputer processing system operates in the second context.
 10. Thedisplay system as set forth in claim 9, wherein said system furthercomprises a cursor located on the display, wherein if said cursor islocated in the first window, the computer processing system operates inthe first context and if said cursor is located in the second window,the computer processing system operates in the second context.
 11. Thedisplay system as set forth in claim 10, further comprising a cursorcontrol device for control of movement of the cursor on the display by auser, said user selecting an item in the first window and dragging theitem to the second window, said computer processing system, when theitem is dragged to the second window, executing the second plurality ofroutines to control objects in the second window.
 12. The display systemas set forth in claim 9, wherein said first and second plurality ofroutines respectively comprise first and second plurality of handlerroutines, each handler routine of the first plurality of handlerroutines, when executed, controlling a portion of the display of thefirst window and each handler routine of the second plurality of handlerroutines, when executed, controlling a portion of the display of thesecond window.
 13. The display system as set forth in claim 12, whereina first routine of the first plurality of handler routines controls thedisplay of the first window and a second routine of the first pluralityof handler routines controls an icon within the first window.
 14. Amethod for controlling user actions within windows in a computercontrolled display system comprising the steps of:a. registering eachroutine of a first plurality of routines for controlling saidcomputer-controlled display system when said system is operable in afirst window and in a first context; b. registering each routine of asecond plurality of routines for controlling said computer-controlleddisplay system when said system is operable in a second window and in asecond context; c. determining if said computer controlled displaysystem is operating in said first context or in said second context; d.automatically sequentially executing each routine of said firstplurality of routines when the system is operating in the first contextsuch that at least one of said first plurality of routines controls thefirst window; and e. automatically sequentially executing each routineof said second plurality of routines when the system is operating in thesecond context, such that at least one of said second plurality ofroutines controls the second window.